PHP Code:
<?
$select = 'SELECT DISTINCT id, name, firstnames, phone';
$from = ' FROM clientinfo';
$where = ' WHERE 1=1';
$searchtext = $_POST['searchtext'];
if ($searchtext != '') { // Some search text was specified
$where .= "AND name LIKE '$name'";
}
?>
</p>
<table width="450">
<?php
$clients = @mysql_query($select . $from . $where);
if (!$clients) {
echo '</table>';
exit('<p>Error retrieving info from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}
/* I added this -----------------*/
$result = mysql_num_rows($clients);
if($result < 1) {
exit('Sorry, no user found.');
} else {
/* ------------------- */
while ($client = mysql_fetch_array($clients)) {
echo "<tr valign='top'>\n";
$id = $client['id'];
$name = $client['name'];
$firstnames = $client['firstnames'];
$phone = $client['phone'];
}
}
?>
Bookmarks