hallo guys
i have a [I]search.php
it does [I](i am sure you know what it does)
so when search keyword/s are posted.. it connects to mysql and makes search.. after search is done… it displays something similar to this:
[B]Search KeyWord Was “some word”
and then displays how many [COLOR=”Gray”
[B]Search Keywird was “some word”, and 15 results are found.
if there was [B]ZERO
[B]Search Keywird was “some word”, and 15 results are found.
so i want to do something like this:
if there were some matches in search
to display: your search word was : [B]search word
[B]15 results found.
otherwise (else)
if search result == 0 to say: sorry, No Matches for your search
so please maybe someone will help me to add such feature to script.
THANK YOU.
[CODE]
<?php
include (“./includes/vars.php”);
$keyword = $_POST[‘keyword’];
mysql_connect(“$localhost”, “$username”, “$password”) or die(mysql_error());
mysql_select_db(“$database”) or die(mysql_error());
$query = “SELECT * FROM mynews WHERE date like ‘%$keyword%’ or title like ‘%$keyword%’ or subtitle like ‘%$keyword%'”;
if (strlen($keyword) > 0)
{
mysql_connect(“localhost”, “$username”, “$password”) or die(mysql_error());
mysql_select_db(“$database”) or die(mysql_error());
$query = “SELECT * FROM mynews WHERE date like ‘%$keyword%’ or title like ‘%$keyword%’ or subtitle like ‘%$keyword%’ or rte1 like ‘%$keyword%'”;
$result = mysql_query($query) or die(mysql_error());
$num=mysql_num_rows($result);
print “<br><br>”;
echo “<div class=’subtitle’> - you searched for <B>$keyword</B> -ს, found <B>$num</B> results</div>”;
print “<br><br>”;
while($row = mysql_fetch_array($result))
{
print “<table border=’0′ cellpadding=’0′ cellspacing=’0′ height=”40″ width=”100%”>”;
print “<TR><TD valign=”top” width=”10%” class=’newsdate’ align=’left’>”.$row[‘date’].”</TD><TD valign=”top” class=’newstitle’ height=’20’><a href=’index.php?p=1&sec_id=”.$row[‘id’].”‘>”.$row[‘title’].”</a></td>”;
print “<TR><TD class=’subtitle’ colspan=’2′>”.$row[‘subtitle’].”</td></TR>”;
print “<TR><TD align=’right’ height=’20’ colspan=’2′><a class=’more’ href=’index.php?p=1&sec_id=”.$row[‘id’].”‘>read more</a></td></TR>”;
print “</table>”;
print “<br />”;
}}
else
{
echo “ <div class=”subtitle”>empty search field !</div> “;
}
?>