I have example table date_table, as a basis of data filter 2 columns - day and day_of_week I do query in SQL
select distinct day_of_week,day from date_table
order by day_of_week
No problem
day_of_week day
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
7 Sunday
Then I implement this into select box in PHP , so I can choose value
$query = "
select distinct day_of_week,day from date_table
order by day_of_week
";
$res = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
$option = '';
while($row = mysql_fetch_array($res))
{
if(!empty($_REQUEST["sday"]))
{
if($row['day_of_week'] == $_REQUEST["sday"])
$option .= '<option value = "'.$row['day_of_week'].'"
selected="selected">'.$row['day'].'</option>';
else
$option .= '<option value =
"'.$row['day_of_week'].'">'.$row['day'].'</option>';
}
else
$option .= '<option value = "'.$row['day_of_week'].'">'.$row['day'].'</option>';
}
And Select Box
<select name="sday" class="sday">
<option value="">Select Day</option>
<?php echo $option; ?>
</select>
- Problem 1
the end Result is something Like
Monday
Friday
Saturday
Sunday
Thursday
Tuesday
Wednesday
- Problem 2
When I select Value "Monday" , all fine . It passes value "1"
When I select "Tuesday", It selects value 2,3 and 7. Same with wednesday and sunday.
There are few other select boxes, that are made with same idea, works fine. There are no data duplicates.
What could be the problem?
$option5 .=?$_REQUEST["sday"]?