Jump to content

Doesn't show message when no results


kvnirvana

Recommended Posts

I’ve got a search function from three drop down lists

It works fine, but if there is no results from the search it just shows a blank page where it should show the message ”No results!” What is wrong?

 

 

function search() 
{ 

//base sql 
  $sql = "select * from behan WHERE 1=1"; 

//get the values from the form 
//NOTE: You should do way more valdation on the values before you attempt to process anything 

  if ((!isset($_POST['submit'])) && ($_POST['beha'] != 'choose')) {  search();} else {  if ($_POST['beha'] == ' choose ') {   echo "error beha!<br>";   }   } 
  { 
    $sql .= " and beha like '". addslashes($_POST['beha'])."%' "; 
  } 
  
  if ((!isset($_POST['submit'])) && ($_POST['omraede'] != ' choose ')) {  search();} else {  if ($_POST['omraede'] == ' choose ') {   echo "error område!<br>";   }   }  
  { 
    $sql .= " and omraede like '". addslashes($_POST['omraede'])."%' "; 
  } 
  
if ((!isset($_POST['submit'])) && ($_POST['pr'] != ' choose ')) {  search();} else {  if ($_POST['pr'] == ' choose ') {   echo "error pr!";   }   }  
  { 
    $sql .= " and problem = '". addslashes($_POST['problem'])."' "; 
  } 
  
  
  

  // ADD ORDER BY  
  $sql .= ' order by total_value DESC ';
  
print "<table border=1>";

  //run query 
$result = conn($sql);
  if (!$result){ die("No results due to database error.<br>".mysql_error());  }
  if (mysql_num_rows($result)==0 && mysql_num_rows($result)!=' choose ')
  {
    echo "No results!";
  }

Link to comment
https://forums.phpfreaks.com/topic/202256-doesnt-show-message-when-no-results/
Share on other sites

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.