Christopher
New Member
I want to know how to search a database-you know like the traditional old search box, then to search the database and return the results. I don't know how, but I think it is something like this:
So would that work? I think my query is error prone... And, how would you "search" for two different things? "WHERE title LIKE '$submit' OR summary LIKE '$submit'"?
Thanx.
PHP:
<?php
if($submit)
{
$query = mysql_query("SELECT * FROM content WHERE title LIKE'$search'"));
$count = mysql_num_rum($query);
if($count <= 0)
print "<br><br><center><b>No results found for the query $search</center><br><br>";
else
{
while($result = mysql_fetch_array($query))
{
print "<br><br>";
print "Title: <a href=\"page.php?id=$result[id]\">$result[title]</a><br>";
print "<br>$result[summary]";
}
}
}
else
{
?>
<form action="<? $PHP_SELF ?>" method="post">
Search: <input type="text" name="search"><br>
<input type="submit" name="submit" value="Search!">
</form>
<?
}
?>
So would that work? I think my query is error prone... And, how would you "search" for two different things? "WHERE title LIKE '$submit' OR summary LIKE '$submit'"?
Thanx.