slaterino Posted January 27, 2010 Share Posted January 27, 2010 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 https://forums.phpfreaks.com/topic/189933-adding-condition-into-mysql-search-function/ Share on other sites More sharing options...
RussellReal Posted January 27, 2010 Share Posted January 27, 2010 <?php if (mysql_num_rows($query)) { while ($row = mysql_fetch_assoc($query)) { // do whatever } } else { // no results found } ?> Link to comment https://forums.phpfreaks.com/topic/189933-adding-condition-into-mysql-search-function/#findComment-1002179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.