Simply search script help required
Posted: Tue Feb 08, 2005 4:14 am
Hi,
I had a search script running using just a search field. here is the sql code which worked;
I want to add a selection box. The selection box will contain a range of columns that are created within my database, i.e. type, IP, software and so on.
Here is what I tried, but failed with;
I also included above this;
Here is the complete code which worked for the search field without the selection box;
feyd | I'm getting tired of editing your posts.
I had a search script running using just a search field. here is the sql code which worked;
Code: Select all
$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");Here is what I tried, but failed with;
Code: Select all
$result = mysql_query("SELECT * FROM dedicated WHERE '%$selection%' LIKE '%$search%'");Code: Select all
$search=$_POSTї"search"];Code: Select all
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","giacom-admin","snooker");
//select which database you want to edit
mysql_select_db("audit");
$search=$_POSTї"search"];
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");
//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $rї"nameofmysqlcolumn"];
//modify these to match your mysql table columns
$asset=$rї"asset"];
$title=$rї"title"];
$customer=$rї"customer"];
$type=$rї"type"];
$IP=$rї"IP"];
$os=$rї"os"];
//display the row
echo "$asset <br> $title <br> $customer <br> $type <br> $IP <br> $os <br>";
}
?>feyd | I'm getting tired of editing your posts.