This one should be easy for someone to explain, but for the life of me, despite hours of looking around or increasingly annoying syntax errors I just cant seem to get it to do what I want.
This is a portion of code from an editing page in the admin area of my site.
Its obvious what it does I think, but anyway, I want to be able to edit sql entries, which it does just fine and dandy, however, the geo_id is in the form of a drop down list, which it calls correctly and everything displays fine. It even posts fine when I make changes.
What I would really like it to do however, is display the correct “geo_id” when it retrieves the information. Currently, no matter what the geo_id of the country is in the sql, it always defaults to the first one in the list (sorted by asc from the sq query).
Question : What am I doing wrong?
I realise the issue is around this area
[code]echo”<option value=””.$geo_info[‘geo_id’].””>”.$geo_info[‘geo_name’].”</option>”;
I also realise I need to tell the option value to use the default (in this case from the country I am editing, which is stored under $myrow[‘geo_id], but I am just not sure how to get it into that piece of code above.
Any help would be appreciated as ive now run out of ciggys and drunk too much coffee :p
Full code below.
[code]
<table width=”600″ align=”center” cellspacing=”0″ cellpadding=”0″ border=”0″>
<tr>
<form action=”<?php echo “http://”.$host.”/ranks/admin/?action=edit_country”;?>” method=”post”>
<input type=hidden name=”country_id” value=”<?php echo $myrow[“country_id”] ?>”></tr>
<tr>
<td> Country :</td><td><INPUT TYPE=”TEXT” NAME=”country_name” VALUE=”<?php echo $myrow[“country_name”] ?>”></td>
</tr>
<tr>
<td>Flag File :</td><td><INPUT TYPE=”TEXT” NAME=”country_flag” VALUE=”<?php echo $myrow[“country_flag”] ?>”></td>
</tr>
<tr>
<td>GeoGraphy :</td><td><select name=”geo_id” class=”event” >
<?php
$sql = “Select geo_name, geo_id from geo order by geo_name asc”;
$result = $db->sql_query($sql);
if($geo_info = $db->sql_fetchrow($result))
{
do
{
echo”<option value=””.$geo_info[‘geo_id’].””>”.$geo_info[‘geo_name’].”</option>”;
}
while($geo_info = $db->sql_fetchrow($result));
$db->sql_freeresult();
}
?>
</select></td>
</tr>
<tr>
<td>Country Pic :</td><td><INPUT TYPE=”TEXT” NAME=”country_pic” VALUE=”<?php echo $myrow[“country_pic”] ?>”></td>
</tr>
<tr>
<td><input type=”submit” class=”event_button”></td></tr>
</form>
</table>