CHANGE:
<?
if ($Industry != "") {
echo "$msg";

} else {
echo "$contact_list";
}
?>

TO:
if( mysql_num_rows($result) > 0 )
{
echo "$contact_list";
}
else
{
echo "$msg";
}


-----Original Message-----
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 12:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Search results


I have done a search page based on a specific column name, but in some
columns there is no results to be returned..

What I would like to do is display an error message stating that there is no
results .. something like "Sorry your search returned Zero Rows"
=============================================================
Here is my code:

<?
$connection = @mysql_connect($databaseserver, $databaseuser, $databasepass)
or die("Can't connect to DB");
$db = @mysql_select_db($databasename, $connection) or die("could not select
DB");
$sql = "SELECT id, FirstName, LastName FROM Canidate WHERE Industry =
\"$Industry\"";
$result = @mysql_query($sql, $connection) or die("could not execute query");

$contact_list = "<ul>";
while ($row = mysql_fetch_array($result)) {

$id = $row["id"];
$FirstName = $row["FirstName"];
$LastName = $row["LastName"];
$contact_list .="<li><a href=\"show_can.php?id=$id\">$LastName,
$FirstName</a>";
}
$contact_list .="</ul>";
$msg = "<font face=\"arial\"><p align=\"center\">Sorry, Your Search Results
Returned Zero Records</p></font>";
?>

<html>
<head>
<title>Your Search Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p align="center"><font face="Arial, Helvetica, sans-serif"><u>Your Search
Results
  for <b> &quot;
  <? echo "$Industry"; ?>
  &quot; </b></u></font></p>
========================== this is the code block that is stumping me
<?
if ($Industry != "") {
echo "$msg";

} else {
echo "$contact_list";
}
?>
================================
<p align="center"><a href="admin.htm"><font face="Arial, Helvetica,
sans-serif">Go
  Back to Main Menu</font></a></P>

</body>
==============================================================



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to