double chained drop down from database


Select A Year:
--SELECT ONE-- 1984 1985 1986 1987
Select A Make:


<?php $year=$_REQUEST['year']; switch($year){ case 1984: $makeArr = array("Honda","Toyota","Volvo","BMW"); break; case 1985: $makeArr = array("Honda","Ford","Nissan","Mercury"); break; case 1986: $makeArr = array("Lincoln","Pontiac","VW","Dodge"); break; case 1987: $makeArr = array("Scion","Jeep","GMC","Chevy"); break; default: $makeArr = array("--Select A Year--"); } $html_to_be_echoed = ""; for($i = 0; $i < count($makeArr); $i++){ $html_to_be_echoed .= "$makeArr[$i]"; } $html_to_be_echoed .= ""; echo $html_to_be_echoed; ?>

it sounds to be simple .but i want tested code where data in both the drop down menu to come from database
e.g:year table having year,id
car table having car ,id,car_id
1st query would be select * from year
2nd query would be select * from car where id=$id(that which we pass)

having problem .Pls help .its urgent.tried but not working

thanks in advance

This is actually not a PHP question, this is more javascript and Ajax question. With jQuery (javascript library) this task will be not too difficult.

Sponsor our Newsletter | Privacy Policy | Terms of Service