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? 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. 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
Archived
This topic is now archived and is closed to further replies.