hi all ,
I have problem with my code ,is not working , my code is like filtering records
i have in my form 5 drop-down list
my code is
<?php
include('conit.php');
include("resqry.php");
$paging_results = new MySQLPagedResults("SELECT count(*) FROM
users ","page","",5,10,">>>","Previous","Next","<<<"," | ");
$pages_nav = $paging_results->getPagesNav();
$offset = $paging_results->currentOffset();
$results_per_page = $paging_results->results_per_page;
$where = array();
$genders = array(female,male);
$countrystayings = array('uk','usa','france','italy','spain');
$contryorgins = array('uk','usa','france','italy','spain');
$nationalitys = array('uk','usa','france','italy','spain');
if (in_array($sex,$genders)){
$where[] = "sex = '{$sex}'";
}
if (in_array($countrystaying,$countrystayings))
{
$where[] = "countrystaying= '{$countrystaying}'";
}
if (in_array($contryorgin,$contryorgins))
{
$where[] = "contryorgin = '{$contryorgin}'";
}
if (in_array($nationality,$nationalitys))
{
$where[] = "nationality = '{$nationality}'";
}
if(isset($_POST['agemax']) && is_numeric($_POST['agemax']))
$agemax = $_POST['agemax'];
else
$agemax = 80;
if(isset($_POST['agemin']) && is_numeric($_POST['agemin']))
$agemin = $_POST['agemin'];
else
$agemin = 0;
$where[] = 'age BETWEEN '.$agemin.' AND '.$agemax;
$Q=implode(' AND ',$where);
$X = mysql_query($Q);
if(isset($_POST['orderby']))
$orderby=$_POST['orderby'];
$res= "SELECT * FROM users WHERE $Q ORDER BY '$orderby' DESC LIMIT $offset,$results_per_page";
$query = mysql_query($res);
$counter = 1;
while($row = mysql_fetch_assoc($query)){ ................. etc
as you can see I have in my form 5 drop-down list
1-sex
2-staying
3-orgin
4-nationlity
5-order by
for example
if I select male in first selection , usa in second , france in third ,usa in forth , and select ordered by age
should give the people who are males ,staying in usa , their origin from france and have usa nationality, will be order by age from younger to older
the thing not working sex ,, when ever select female or male will give me all and that's problem ..
about countries working fine
about order by not working
so two fields not working fine sex and order by
what is wrong with my code ????