Help with passing drop down info

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sylunt1
Forum Newbie
Posts: 1
Joined: Mon Feb 16, 2004 1:42 am
Location: San Jose, CA

Help with passing drop down info

Post by sylunt1 »

Greetings:

OK here's what I am trying to do:

I want to be able to select an item from the dropdown box - press a submit type button and then have it display an id number (city_id) - fairly simple, but I am having issues. I don't know where to put the code to get the button for starters. I can do it using manual text entry in htlm, but this is beyond that.

Any help would be appreciated.

Code: Select all

<?php
$result = mysql_query ("SELECT bm_city.city_id, bm_city.city_name, bm_city.state_id, bm_state.state_name, bm_state.state_id
FROM bm_city, bm_state 
WHERE bm_city.state_id = bm_state.state_id
ORDER BY bm_city.city_name") or die(mysql_error()); 

echo "<select name='city'>";  
while($row = mysql_fetch_array($result))
{
    $city_name = $row['city_name'];
    $city_id = $row['city_id']; 
    $state_name = $row['state_name'];
    $state_id = $row['state_id'];

    echo "<option value='$city_id'";
    if($_POST['city_id']==$city_id) echo "selected";
    echo ">$city_name</option>\n";             
}
echo "</select>";
?>
Post Reply