simply search script
Posted: Mon Feb 07, 2005 10:51 am
Hi,
I have a search form on my main page which the user can insert some text and then select a table to search in. The problem is, is that the search brings up every record in the database. It worked before I inserted the list menu to choose a table to search in.
Here is the code for the form;
PLease help
feyd | please use the formatting we provide
I have a search form on my main page which the user can insert some text and then select a table to search in. The problem is, is that the search brings up every record in the database. It worked before I inserted the list menu to choose a table to search in.
Here is the code for the form;
Code: Select all
<form action="search.php" method="post" name="search" id="search" style="display:inline">
<img src="search.gif" width="11" height="21">
<input type="text" name="search" size=25 maxlength=25>
<select name="selection" id="selection">
<option>asset</option>
<option>customer</option>
</select>
<input type="Submit" name="Submit" value="Search">
</form>
and here is the search.php code....
<?
mysql_connect("localhost","giacom-admin","snooker");
mysql_select_db("audit");
$search=$_POSTї"search"];
$selection=$_POSTї"search"];
$result = mysql_query("SELECT * FROM dedicated WHERE '%$selection%' LIKE '%$search%'");
while($r=mysql_fetch_array($result))
{
$asset=$rї"asset"];
$title=$rї"title"];
$customer=$rї"customer"];
$type=$rї"type"];
$IP=$rї"IP"];
$os=$rї"os"];
echo "$asset <br> $title <br> $customer <br> $type <br> $IP <br> $os <br>";
}
?>PLease help
feyd | please use the formatting we provide