the latest
October 20, 2008 New Backup Script has been launched. Some house keeping has been done around the site and we have a few new items to be added soon.

the greatest

» Backup Script
» Contact Script
» PHP Includes
» Image Gallery

MySQL Search

Description

A simple search of a mysql database.

Tutorial

The example below shows you how to search "-table-" for any matching entries in the "-title-" and "-info-" columns. Replace these with your own names. The results are then displayed in a table.

The Form:

<form action="searchresults.php" method=post>
<input type="text" name="search">
<input type=submit value="Search" name=search>


The Results:

<?php

$result = mysql_query("SELECT id,title FROM -table- WHERE `-title-` LIKE '%".$search."%' OR `-info-` LIKE '%".$search."%' order by id desc");


echo'<table width=100% cellspacing=0 cellpadding=4 id=content bgcolor=white>
<tr><td id=heading colspan=3>Search Results - '.$search.'</td></tr>';

$row_count = 0;

while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$title=$r["title"];

echo "<tr><td><a href=\"show.php?postid=$id\">$title</a></td></tr>";

$row_count++;
}

echo "</table>";

?>


Home : Services : Scripts : Tutorials : Hosting : Contact