I m trying to get it work in php but i cant, since i m new in PHP :( i was wondering if someone can help and i would really appreciate it!! :*
Description:
In a php page i want to choose from a drop down menu (Houses) a choise for example a house and after that on a second drop down menu below to show me automatically the rooms of the house i choosed on the menu above..
I created 2 tables on a database houses_db in mysql
i. one table called houses with one column with house1, house2,...etc
ii. and on second table called rooms with first column called house1 and the rooms in it, second column house2 and the rooms in it and so on..
so on the php page when i select from the first menu a house on the second menu to show me the rooms that it has
i hope that was clear enough, i m sure this can be done with a mysql query but i dont kno how i write something but it doesnt work i m sure is wrong!!!!!i m confused on the use of the variables..
<?php
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("houses_db",$db);
?>
<select name=rooms>
<?php
$query = "SELECT houses, rooms from rooms";
$result = mysql_db_query($db, $query, $connection) or die ("Error in query: $query. " . mysql_error());
while (list($houses, $rooms) = mysql_fetch_row($result))
{
echo "<option value=$houses>$rooms</option>";
}
mysql_free_result($result);
?>
PLEASE HELP i m so confused!!!!:'(