Hi Everyone.
I have html page coding:
HTML coding.....
---------------------------------------------------
<h2>Search</h2>
<form name="search" method="post" action="Search. php">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="fname">F irst Name</option>
<Option VALUE="lname">L ast Name</option>
<Option VALUE="info">Pr ofile</option>
</Select>
<input type="hidden" name="searching " value="yes" />
<input type="submit" name="search" value="Search" />
</form>
--------------------------------------------------
Now Php Which have to search the database & Print results.
PHP Coding.....
--------------------------------------------------
<?
if ($searching =="yes")
{
echo "<h2>Result s</h2><p>";
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
mysql_connect(" localhost", "root", "") or die(mysql_error ());
mysql_select_db ("db") or die(mysql_error ());
$find = strtoupper($fin d);
$find = strip_tags($fin d);
$find = trim ($find);
$data = mysql_query("SE LECT * FROM users WHERE upper($field) LIKE'%$find%'") ;
while($result = mysql_fetch_arr ay( $data ))
{
echo $result['fname'];
echo " ";
echo $result['lname'];
echo "<br>";
echo $result['info'];
echo "<br>";
echo "<br>";
}
$anymatches=mys ql_num_rows($da ta);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
echo "<b>Searche d For:</b> " .$find;
}
?>
--------------------------------------------
The problem is that it cannot display the Results.
Whats wrong with this code.
Can anyone help me.
Thanks.
I have html page coding:
HTML coding.....
---------------------------------------------------
<h2>Search</h2>
<form name="search" method="post" action="Search. php">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="fname">F irst Name</option>
<Option VALUE="lname">L ast Name</option>
<Option VALUE="info">Pr ofile</option>
</Select>
<input type="hidden" name="searching " value="yes" />
<input type="submit" name="search" value="Search" />
</form>
--------------------------------------------------
Now Php Which have to search the database & Print results.
PHP Coding.....
--------------------------------------------------
<?
if ($searching =="yes")
{
echo "<h2>Result s</h2><p>";
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
mysql_connect(" localhost", "root", "") or die(mysql_error ());
mysql_select_db ("db") or die(mysql_error ());
$find = strtoupper($fin d);
$find = strip_tags($fin d);
$find = trim ($find);
$data = mysql_query("SE LECT * FROM users WHERE upper($field) LIKE'%$find%'") ;
while($result = mysql_fetch_arr ay( $data ))
{
echo $result['fname'];
echo " ";
echo $result['lname'];
echo "<br>";
echo $result['info'];
echo "<br>";
echo "<br>";
}
$anymatches=mys ql_num_rows($da ta);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
echo "<b>Searche d For:</b> " .$find;
}
?>
--------------------------------------------
The problem is that it cannot display the Results.
Whats wrong with this code.
Can anyone help me.
Thanks.
Comment