[B]hello,
i want to search my database and i created search.php file.
here is the code:
[CODE]<?php
mysql_connect(“localhost”, “root”, “”) or die(mysql_error());
mysql_select_db(“mynews”) or die(mysql_error());
$query = “SELECT * FROM newsdb WHERE date like ‘%$keyword%’ or title like ‘%$keyword%’ or rte1 like ‘%$keyword%'”;
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
print “<table cellpadding=0 cellspacing= width=100% width=700>”;
print “<tr><td height=20 class=”date” bgcolor=#E0E0E0 style=”BORDER-BOTTOM:1px #1E90FF solid;”> <B>”; echo $row[‘date’]; print “</B></td></tr>”;
print “<tr><td>”; print “<br>”; echo $row[‘title’]; print “</td></td>”;
print “<tr><td align=right>”;
echo “<a class=”more” href=’read_news.php?id=”.$row[‘id’] .”‘>დაწვრილებით…</a>”;
print “<br><br>”;
print “</td></td>”;
print “</table>”;
}
?>
but if the search field is empty and i press “search” button, search.php displays all the data from DB, instead of this i want something like this: if searchword is not specified to echo “please insert search word” but if the searchword is inserted to do the action from above code.
how can do that? i know its if statmant function but could not write it right way.. please help me.