Greetings I have been working on this for two days ..just a beginner..thanks ladies and gents for your time to look at this post..
I have 3 combo boxes that are loaded from a database.. I want to save the changed state from one box and load the other dependant boxes based on the prior selections ...
after I have the vlaues I will use them to query a database to find ..dealers in that county . state and city..
It kind of works so far ..but it does not hold the values very well..
Any ideas or tutorials will be appreciated... I have searched the site here ..but could not find anything suitable... when I ( us 🙂 lol ... complete this I will repost for others to use..
thanks in advance
here is a link to what I have so far
http://usedcarcalifornia.com/queries/reload.php
// code below
<?php
$mysql_server = "localhost";
$mysql_username ="";
$mysql_password ="";
$mysql_dbname = "";
$link = mysql_connect($mysql_server, $mysql_username, $mysql_password);
if (!$link) { echo("error - can't connect to dbase"); exit();}
$db = mysql_select_db("$mysql_dbname");
if (!$db) { echo("error - dbase does not exist"); exit();}
// start countries
echo"<form name=country method='post' action=''>
<table border='1'>
<tr>
<td width=200 >country</td>
<td>
<select name='country' onChange='this.form.submit()' class=form180>
<option value='search.php'>------- SELECT ONE -------</option>";
$getcountries = mysql_query("SELECT country_id, country_name FROM countries");
while($row = mysql_fetch_array($getcountries))
{
echo("<option value='$row[country_id]'>$row[country_name]</option>");
}
echo"</select></td>
</tr></table></form>";
$country_id=$_POST[country];
//echo"$country_id";
// start states
echo"<form name=state method='post' action=''>
<table border='1'>
<tr>
<td width=200 >state</td>
<td><select name='state' onChange='this.form.submit()'>
<option selected>------- SELECT ONE -------</option>";
$getstates = mysql_query("SELECT state_id, state_name FROM states where country_id='$country_id'");
while($row = mysql_fetch_array($getstates))
{
echo("<option value='$row[state_id]'>$row[state_name]</option>");
}
echo"</select></td>
</tr></table></form>";
$state_id=$_POST[state];
//echo"$state_id";
// start cities
echo"<form name=city method='post' action=''>
<table border='1'>
<tr>
<td width=200 >city</td>
<td><select name='city' onChange='this.form.submit()'class=form180>
<option selected>------- SELECT ONE -------</option>";
$getcities = mysql_query("SELECT city_id, city_name FROM cities where state_id='$state_id'");
while($row = mysql_fetch_array($getcities))
{
echo("<option value='$row[city_id]'>$row[city_name]</option>");
}
echo"</select></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Submit' value='Reload'></td>
</tr>
</table>
</form>";
$city_id=$_POST[city];
//echo"$city_id";
?>