Hi I want to have 2 select dropdown based on the value of 1st drop down without submit button.
But I m not getting dynamically the selected value in 1st drop down eg: year , so that i can use it for next selection. can anyone plz help me
Eg:
<?php
mysql_connect('localhost','root','root');
mysql_select_db("dump");
$result = mysql_query("SELECT DISTINCT year FROM date order by year ASC");
echo "<select name = 'year' >";
if(isset($_POST['year']))
{
echo "<option value='{$_POST['year']}'>{$_POST['year']} </option>";
}
else
{
echo "<option value='Select year'> Select year </option>";
}
while($row = mysql_fetch_array($result,MYSQL_NUM))
{
if($_POST['year']!=$row[0])
{
echo "<option value={$row[0]}>{$row[0]}</option>";
}
}
echo "</select> ";
echo $year;
// but the selected year is not getting echoed
?>
// get the year based on selection done
<select name="table3" onChange="form1.submit()">
<?php
$name=$_SERVER['HTTP_GSSO_USER'];
mysql_connect('localhost','root','root');
mysql_select_db("dump");
$query = "SELECT DISTINCT(month) FROM date where year = <?php echo $year; ?> order by month asc;";
echo $query;
$result = mysql_query("SELECT DISTINCT year FROM date order by year ASC");
echo "<select name = 'month' >";
if(isset($_POST['bin']))
{
echo "<option value='{$_POST['month']}'>{$_POST['month']} </option>";
}
else
{
echo "<option value='Select month'> Select month </option>";
}
while($row = mysql_fetch_array($result,MYSQL_NUM))
{
if($_POST['bin']!=$row[0])
{
echo "<option value={$row[0]}>{$row[0]}</option>";
}
}
echo "</select> ";
?>