Имеется 2 select box:
1ый select
<select name="sex" onChange="history(window.location='index.php?sex='+this.value);">
<option value="" <?PHP if(isset($_GET['sex'])){if($_GET['sex']=='') echo ' selected="selected"';}?>>Все</option>
<option value="Мужской" <?PHP if(isset($_GET['sex'])){if($_GET['sex']=='Мужской') echo ' selected="selected"';}?>>Мужской</option>
<option value="Женский"<?PHP if(isset($_GET['sex'])){if($_GET['sex']=='Женский') echo ' selected="selected"';}?> >Женский</option>
</select>
2ой select
<select name="group" onChange="history(window.location='index.php?group='+this.value);">
<option value="" <?PHP if(isset($_GET['sex'])){if($_GET['sex']=='') echo ' selected="selected"';}?>>Все</option>
<?
do {
?>
<option value="<?=$myrow['group'];?>" <?PHP if(isset($_GET['group'])){if($_GET['group']==$myrow['group']) echo ' selected="selected"';}?>><?=$myrow['group'];?></option>
<?
}
while ($myrow = mysql_fetch_array($result));
?>
</select>
Допустим я выбираю пол - Женский, затем группу, после этого происходит обновление станицы с переменной группы (обработчик находится на этой странице), а пол возвращает в первоначальное значение. Так вот как сделать так чтобы он выводил ту запись где был выбранный пол и группа?
Вот обработчик
if (isset($_GET['sex']))
{
$sex=$_GET['sex'];
}
if (isset($_GET['group']))
{
$group=$_GET['group'];
}
?>
<?php
if (!$sex and !$group)
{
$result=mysql_query("SELECT * FROM `man`");
$rows=mysql_fetch_array($result);
do {
echo "<tr>
<td>" . $rows['name'] . "</td>
<td>" . $rows['sex'] . "</td>
<td>" . $rows['group'] . "</td>
</tr>";
}
while ($rows=mysql_fetch_array($result));
}
elseif (isset($sex) and isset($group))
{
$result=mysql_query("SELECT * FROM `man` WHERE `sex`=\"$sex\" and `group`=\"$group\"");
$rows=mysql_fetch_array($result);
do {
echo "<tr>
<td>" . $rows['name'] . "</td>
<td>" . $rows['sex'] . "</td>
<td>" . $rows['group'] . "</td>
</tr>";
}
while ($rows=mysql_fetch_array($result));
unset($sex);
unset($group);
}
{
$result=mysql_query("SELECT * FROM `man` WHERE `sex`=\"$sex\"");
$rows=mysql_fetch_array($result);
do {
echo "<tr>
<td>" . $rows['name'] . "</td>
<td>" . $rows['sex'] . "</td>
<td>" . $rows['group'] . "</td>
</tr>";
}
while ($rows=mysql_fetch_array($result));
$result=mysql_query("SELECT * FROM `man` WHERE `group`=\"$group\"");
$rows=mysql_fetch_array($result);
do {
echo "<tr>
<td>" . $rows['name'] . "</td>
<td>" . $rows['sex'] . "</td>
<td>" . $rows['group'] . "</td>
</tr>";
}
while ($rows=mysql_fetch_array($result));
}