Hello again...
Could somebody please advise me on the following (and bear with me...Im a newbie)
I was trying out this code for a dependant drop down list for country and state from this site:
http://javascript.internet.com/forms...drop-down.html
It works fine but when I use php to put selected options in the mysql tables I created and display the outcome it displays the country and state code and not the actual name.(for example: I select United Sates and Texas it will display US and TX instead of the whole name, so its saving the codes instead of the names) Im sure I am doing something small wrong but thats what you get for being a newb! I have tried to break down my code as much as possible and maybe somebody could help me in the right direction.
The javascript is at the address above and here is on my page:
this is the code on my page that creates the list boxes and it shows up fine:
Code:
<td height="21" colspan="2" valign="top"><font color="#FF0000" size="1">Please
select your country/state</font> <font color="#FF0000">*</font></td>
<td></td>
</tr>
<tr>
<td height="27" valign="top">
<select id='countrySelect' name='country' class="required" onchange='populateState()'>
</select>
</td>
<td valign="top">
<select id='stateSelect' name='state'>
</select>
<script type="text/javascript">initCountry('PLS'); </script>
<td></td>
</tr>
Then I have this php to send it to mysql table (I am not including the whole page, just the php related to this problem):
Code:
mysql_query("UPDATE users SET
`country` = '$_POST[country]',
`state` = '$_POST[state]',
WHERE id='$_SESSION[user_id]'
") or die(mysql_error());
On the profile page it displays it with this php:
Code:
$result = mysql_query("select * from users where id='$_SESSION[user_id]'");
//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$country=$r["country"];
$state=$r["state"];
//display the row
echo " <br> $country <br> $state <br> ";
}
There is a row in the mysql table called country, varchar(200), not null
and the same for state called state.
Appologies in advance for the long post but I thought I better add all details I might need.
Thanks again for your time.
Clint
