here is the code I use. I use this on the front page of my site:
<form action="index.php" method="post">
<input type="hidden" name="content" value="search.php">
<input type="text" name="searchstring" cols="10">
Search the site
</textarea><br />
<input type="submit" value="SEARCH" />
</form>
what this does is reload the page when you submit with as if you had doen the following:
"http://.../index.php?content=search.php&searchstring=your+search"
now the code on reload is here:
connect to your databaseserver
select database
$search_result = @mysql_query("SELECT NewsTitle, NewsDate, NewsBody, NewsAuthor, name, email FROM content, authors WHERE NewsAuthor=authors.ID AND NewsBody LIKE '%$searchstring%' ORDER BY NewsDate DESC");
while ($data = mysql_fetch_array ($search_result)) {
$newstitle = $data["NewsTitle"];
$newsbody = $data["NewsBody"];
$newsdate = $data["NewsDate"];
$name = $data["name"];
$email = $data["email"];
echo"<tr><td class='newstitle'>$newstitle</td></tr>" .
"<tr><td class='newsdate'>$newsdate</td></tr>" .
"<tr><td class='newspost'>$newsbody</td></tr>" .
"<tr><td class='normal'> Posted by:<a href='mailto:$email'>$name </a></td></tr>";
}
This searches through news on my site and posts results in a table format with css formatting included ("class=").
It took me a while to tweak this and I know it works, so if you have questions, feel free to mail me.