Reputation: 7
I'm not sure why this is not working:
if($strFilterByStatus != 'all' && $strFilterByYear == 'all' && $strFilterByMonth !='all')
{
$strSQL = "SELECT * FROM tblcase where recovered = '".$strFilterByStatus."' and monthreported = '".$strFilterByMonth."'" ;
}
else if($strFilterByStatus != 'all' && $strFilterByYear != 'all' && $strFilterByMonth !='all')
{
$strSQL = "SELECT * FROM tblcase where recovered = '".$strFilterByStatus."' and yearreported = '".$strFilterByYear."' and monthreported = '".$strFilterByMonth."'" ;
}
if (mysql_num_rows($strSQL)==0)
{
$strCaseExist = false;
}
else
{
$SQL=mysql_query($strSQL);
$strCaseExist = true;
}
I have 2 different SQL statements and I just want to know if it will return a record or not.
Upvotes: 0
Views: 56
Reputation: 80629
mysql_num_rows
requires a resultset to be passed not a string variable. Change to the following code:
$result = mysql_query( $strSQL );
$strCaseExist = (mysql_num_rows($result) == 0) ? false : true;
Upvotes: 2