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

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.