0

How to get the scheduleID value from a comboBox within a specific MovieID value from another comboBox?


comboBox Movie

<?php       
$query = "select * from ref_movies ORDER BY MovieID";
$result = mysql_query($query) or die (mysql_error());

echo '<select name="MovieID" ><option value="">---Select Movie---</option>';

while ($row = mysql_fetch_assoc($result))
{
    echo "<option value='" . $row['MovieID'] ."'>" . $row['MovieTitle'] ."</option>"; 
}
echo '</select>';
?>


comboBox Schedule

<?php
$query = "select * from schedule ORDER BY scheduleID";
$result = mysql_query($query) or die (mysql_error());

echo '<select name="ScheduleID" ><option value="">---Select Time---</option>';

while ($row = mysql_fetch_assoc($result))
{
    echo "<option value='" . $row['ScheduleID'] ."'>" . $row['MovieDATETIME'] ."</option>"; 
}
echo '</select>';
?>
  • You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Sep 01 '14 at 15:26
  • A combobox is a UI control that is a combination (hence the name) of a drop down menu (which is what you get with a select in HTML) and a text input (an input of type text). HTML doesn't have any native controls that are represented as comboboxes. You have "a select element". – Quentin Sep 01 '14 at 15:26

1 Answers1

0

Put the two PHP scripts in separate files.

Set the form action in the first one to the URL of the second one.

Read the value from $_GET['MovieID'].

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Both dropdown lists are only to be selected, not submitted. So everytime a user selects any value in the Movie dropdown list, it generates all values in the database to the Schedule dropdown list – user3811657 Sep 01 '14 at 15:33
  • Then you'll need to use JavaScript and either store all the data in that might be in the second select in the page or write a websevice and fetch the data with Ajax. – Quentin Sep 01 '14 at 15:35