Reputation: 2477
I have the following in my data
Year Week
2011 19
2011 18
2011 17
2012 1
I have created a drop down list form for display the info
<script type="text/javascript">
function getWeek()
{
if (document.getElementById('y').value != '')
{
document.getElementById('d').disabled = ''; // this will enable the select
}
}
</script>
<form name="myform" action="http://www.website.com/displaybook.php" method="get">
<select size="1" name="y" id ="y" onchange="getWeek()">
<?
$sql=mysql_query("SELECT DISTINCT (Year) FROM data ORDER BY Year Desc");
while($row = mysql_fetch_array($sql))
{
echo "<option value='". $row['Year']."'>Season - ". $row['Year']."</option>";
}
?>
</select>
<select size="1" name="d" id="d" disabled="disabled">
<?
$sql=mysql_query("SELECT DISTINCT (Week) FROM data ORDER BY Week ASC");
while($row = mysql_fetch_array($sql))
{
echo "<option value='". $row['Week']."'>Week - ". $row['Week']."</option>";
}
?>
</select>
<input type="submit" value="Get data">
</form>
My problem is that i want it to display for example only week of 2012 when selected 2012 and week 2011 when selected 2011 etc...
Upvotes: 1
Views: 883
Reputation: 6389
Try removing
while($row = mysql_fetch_array($sql))
{
echo "<option value='". $row['Year']."'>Season - ". $row['Year']."</option>";
}
Upvotes: 1