Hi all
really stuck and in desperate need of help!
thanks greensmurf, but thats not what im after
basically, trying to create a results page from a form and need two things that am really stuck on.
- If the form value ="" then i need it to return all the results in that table field.
- I need to then take those results and count certain values. For example, how many case_open fields have the "yes" value and then return that value as a number
Code for part 1.
$ethnic = $_REQUEST['ethnic'];
$gender = $_REQUEST['gender'];
$referral = $_REQUEST['referral'];
$age = $_REQUEST['age'];
$month = $_REQUEST['month'];
$year = $_REQUEST['year'];
$query = "SELECT * from tbl WHERE";
if ((!empty($_POST['ethnic']))&&($_POST['ethnic'] != 'all')) { $query .= " ethnic_background like '". addslashes($_POST['ethnic'])."%' "; }
if ((!empty($_POST['gender']))&&($_POST['gender'] != 'all')) { $query .= " and gender like '". addslashes($_POST['gender'])."%' "; }
if ((!empty($_POST['age']))&&($_POST['age'] != 'all')) { $query .= " and age_range like '". addslashes($_POST['age'])."%' "; }
if ((!empty($_POST['month']))&&($_POST['month'] != 'all')) { $query .= " and date_received_month like '". addslashes($_POST['year'])."%' "; }
if ((!empty($_POST['year']))&&($_POST['year'] != 'all')) { $query .= " and date_received_year like '". addslashes($_POST['year'])."%' "; }
$result = mysql_query($query);
$numrows=mysql_num_rows($result);
if ($numrows == 0)
{
echo "<div class=\"heading\">Sorry, your search returned no results. Please go back and try again!</div>";
}
I then run a loop i.e.
<? while ($row = mysql_fetch_assoc($result)) {
?>
Then i need to return the results below in a table i.e.
<table><tr>
<td valign="top" height="30" style="border-bottom:1px #ccc solid;" class="bodytext_table"><div align="left"> Number of IMHA cases opened</div></td>
<td style="border-bottom:1px #ccc solid;"> <div align="right" style="color:#993366; font-size:12px; font-weight:600;">number here</div></td> </tr></table>
can someone shed some light please, its really urgent and need it tonight and have searched high and low for answers!!!
any help appreciated!
thanks