Jump to content

Recommended Posts

Hi,

 

I have a page displaying a list of records, i want to display these record based on a combo box which just says to display records with status, open, closed or all.

 

im not sure how to do this and im pretty sure im wrong, but heres what i came up with

<?php 
$sql = "";
if(isset($_POST['submit']))
{
$queryvar = $_POST["combo1"];

if ($queryvar == "All")
//Echo "You are viewing all records";
$sql = mysql_query("SELECT * FROM tblworkorders WHERE status = ''");
elseif ($queryvar == "Open")
//echo "you are viewing all Open records";
$sql = mysql_query("SELECT * FROM tblworkorders WHERE status = 'Open'");
elseif ($queryvar == "Closed")
//echo "Viewing all Closed records";
$sql = mysql_query("SELECT * FROM tblworkorders WHERE status = 'Closed'");

}
echo "query" . $sql;
$con = mysql_connect("localhost","root","");

mysql_select_db(it, $con);

$result = $sql;

$num=mysql_numrows($result);

mysql_close();
?>

 

The error i am getting is

 

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\it\ifelsetest.php on line 30

 

im guessing the $sql variable is not global or something, im not too sure.

 

Thanks in advance

 

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.