Page 1 of 1

Make Reports

Posted: Sat Jan 18, 2003 6:49 am
by maskme
Suppose I've Fields

Title
Age
Gender
Country

What I want is that a user selects either of these fields or all of these fields to get a report based on the selection.

For e.g.: A user selects age group from 18-21 & selects country USA, so from the database it will select those records only n give.

Firstly how should i know which of the above fields is selected.

e.g.

-------------------The below is for just one selection-----------------

Code: Select all

if ($title != "") $var = "TITLE = $title"

$squery = "SELECT TITLE, AGE, GENDER, COUNTRY FROM tblparent where $var";
$sresult = mysql_query($squery) or die("Search Query Failed");
-----------------------------------------------------------------------

And if two or more of the fields are selected how should i put AND between them in the Query

Please help!

Yusuf