Forgive me if this is a repeated question but I am having trouble finding the correct wording for my issue. I have a client that wants me to redo their log page. They want a drop-down box with a list of all the unique cities in their database. I have this part done. The next part is when the user clicks on one of the options, all the logs for that city display. My issue is I cannot figure out how to get the value of select box. I know I can do it with a form submit, but I want to be able to click the box and show it in real time. Here is the code for the drop-down if needed:
Drop-down code:
$select = mysql_query("SELECT DISTINCT location FROM tbl_overnight");
if (!mysql_num_rows($select)) {
echo "<option value='none'>No Locations...</option>";
} else {
while ($row = mysql_fetch_assoc($select)) {
echo "<option value='".$row['location']."'>".$row['location']."</option>";
}
};
?>
The code for the logs so far is similar to the code above except for the display. I read somewhere that I may have to use AJAX so I can get the real-time value then convert it to a php variable but I’m not sure if that’s the way to go.
If there is another post that is similar to this that I did not see then please link it in a comment below and I will look at it and remove this posting.
You can’t do this in php you could use ajax and the onChange event in javascipt to do this
this tutorial may will help you to do what you want
http://www.w3schools.com/php/php_ajax_database.asp