Re: Search results

From: Date: Wed, 06 Feb 2002 19:33:59 +0000
Subject: Re: Search results
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-16573@lists.php.net to get a copy of this message
On Thursday 07 February 2002 02:16, Todd Williamsen wrote: > 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)) { $FOUND_SOMETHING = 1; > $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 ($FOUND_SOMETHING) { echo "$contact_list"; } else { echo "$msg"; > } > ?> > ================================ > <p align="center"><a href="admin.htm"><font > face="Arial, Helvetica, > sans-serif">Go > Back to Main Menu</font></a></P> > > </body> > ============================================================== hth -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Lonely is a man without love. -- Englebert Humperdinck */

« previous php.db (#16573) next »