Jump to content

Search result


user4fun

Recommended Posts

i use this format taken from the tutorials, what if i want to display a message if non were found.The trick is that i want the message to be displayed saying non found... before the <th> are displayed.

......$result = mysql_query("SELECT * FROM person WHERE W1='" . strtolower($entry) . "'");echo "<table border='1'><tr><th>Firstname</th><th>Lastname</th></tr>";while($row = mysql_fetch_array($result))  {  echo "<tr>";  echo "<td>" . $row['FirstName'] . "</td>";  echo "<td>" . $row['LastName'] . "</td>";  echo "</tr>";  }echo "</table>";mysql_close($con);

Link to comment
Share on other sites

$result = mysql_query("SELECT * FROM person WHERE W1='" . strtolower($entry) . "'");if(sizeof($results)==0){  echo "No rows found!";}echo "<table border='1'><tr><th>Firstname</th><th>Lastname</th></tr>";while($row = mysql_fetch_array($result))  {  echo "<tr>";  echo "<td>" . $row['FirstName'] . "</td>";  echo "<td>" . $row['LastName'] . "</td>";  echo "</tr>";  }echo "</table>";mysql_close($con);

Link to comment
Share on other sites

hmmmmit is not working, he is what i got

$word = $_POST['word'];$direct_hit = mysql_query("SELECT Website, Email, IDT, W1, W2, W3  FROM confirmed WHERE W1='" . strtolower($word) . "'"); if(sizeof($direct_hit)==0){  echo "No rows found!";}else{echo "<table border='1'><tr><th>Website</th><th>Email</th><th>Identity Tags</th><th>Key 1</th><th>Key 2</th></tr>";$alt = true;while($row = mysql_fetch_array($direct_hit))  {if ($alt)	echo "<tr bgcolor=\"#F2F2F2\">";  else	echo "<tr bgcolor=\"#FFFFFF\">";  $alt = !$alt;		  echo "<td width= '225'><a href=\"http://".$row['Website']."\" target=\"_blank\">".$row['Website']."</a></td>";   	 echo "<td width='225'><font size=\"2\">" . $row['Email'] . "</td>";	 echo "<td><font size=\"2\">"  . $row['IDT'] . "</td>";				 echo "<td><font size=\"2\">" . $row['W2'] . "</td>";				 echo "<td><font size=\"2\">"  . $row['W3'] . "</td>";echo "</tr>";  }echo "</table>";}

Link to comment
Share on other sites

Bit of mental retardation on my part. I'm used to my db object which automatically returns an array instead of the resource. just had to change part of a line.

$word = $_POST['word'];$direct_hit = mysql_query("SELECT Website, Email, IDT, W1, W2, W3  FROM confirmed WHERE W1='" . strtolower($word) . "'");if(mysql_num_rows($direct_hit)==0){  echo "No rows found!";}else{echo "<table border='1'><tr><th>Website</th><th>Email</th><th>Identity Tags</th><th>Key 1</th><th>Key 2</th></tr>";$alt = true;while($row = mysql_fetch_array($direct_hit))  {if ($alt)	echo "<tr bgcolor=\"#F2F2F2\">";  else	echo "<tr bgcolor=\"#FFFFFF\">";  $alt = !$alt;		  echo "<td width= '225'><a href=\"http://".$row['Website']."\" target=\"_blank\">".$row['Website']."</a></td>";		echo "<td width='225'><font size=\"2\">" . $row['Email'] . "</td>";	 echo "<td><font size=\"2\">"  . $row['IDT'] . "</td>";				 echo "<td><font size=\"2\">" . $row['W2'] . "</td>";				 echo "<td><font size=\"2\">"  . $row['W3'] . "</td>";echo "</tr>";  }echo "</table>";}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...