Jump to content

Adding condition into MYSQL search function


slaterino

Recommended Posts

Hi,

I created a simple search function where the user enters a value in a form and then clicks to send. Now, I'm trying to work out how I can display a message if there are no successful search results. This is a snippet from the code that I'm using right now and I can't think what I can do to achieve this. Is there a way of putting a conditional statement in here saying that IF the search statement is not LIKE common_name and genus then do something else? This is only a small job so don't want to have to rewrite all my script sorting this one out. Does anyone have any suggestions?

 

if (!empty($_GET['qsearch'])) {
$search = mysql_real_escape_string( trim($_GET['qsearch']) );
$catalogue_query .=" WHERE Common_Name LIKE '%$search%' OR Genus LIKE '%$search%'";
}

 

Thanks!

Russ

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.