Jump to content

Filtering with an IF statement


spoco

Recommended Posts

Hello. I have created a PHP page with several recordsets that are querying a table and working fine overall. I would like to set up a way on this page to run the same query, but allow the user to select a school (a field in the table) and filter the same results by school.

 

Here is an example of two recordsets (There are 21 in total)

 

mysql_select_db($database_Survey, $Survey);
$query_drops = "SELECT SUM(survey.drops) FROM survey ";
$drops = mysql_query($query_drops, $Survey) or die(mysql_error());
$row_drops = mysql_fetch_assoc($drops);
$totalRows_drops = mysql_num_rows($drops);

mysql_select_db($database_Survey, $Survey);
$query_Recordset2 = "SELECT SUM(survey.poweroutlets) FROM survey ";
$Recordset2 = mysql_query($query_Recordset2, $Survey) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

 

What I would like to do is create a drop down menu with a list of schools in which the user can select and the same results would be displayed, only displayed by school.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.