m00ch0 Posted August 16, 2007 Share Posted August 16, 2007 <?php //connect to mysql mysql_connect("localhost","x","x"); mysql_select_db("x"); $tbl_name="x"; // Table name $search=$_POST["search"]; $result = mysql_query("SELECT * FROM $tbl_name WHERE scan LIKE '%$search%'"); while($row=mysql_fetch_array($result)) { $scan=$row["scan"]; $manufacturer=$row["manufacturer"]; $description=$row["description"]; $code=$row["code"]; $partno=$r["partno"]; $id=$r["id"]; echo "$scan <br> $manufacturer <br> $description <br> $code | $partno <br>"; } ?> the code as you can see searchs only in the scan column how can I get it to search every column apart from id? Quote Link to comment https://forums.phpfreaks.com/topic/65243-small-search-script-search-all-fields/ Share on other sites More sharing options...
Fadion Posted August 16, 2007 Share Posted August 16, 2007 <?php $results = @mysql_query("SELECT * FROM $tbl_name WHERE scan LIKE '%$search%' AND column LIKE '%$search%'") or die(mysql_error()); ?> Use AND to concatenate columns. Quote Link to comment https://forums.phpfreaks.com/topic/65243-small-search-script-search-all-fields/#findComment-325869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.