I am eager to put a search tool on my site, however there is a slight problem.... I'm a PHP NOOB. :-O Can anybody point me to a easy, but sufficient tutorial on how to implement the search feature on your site? Or even give me steps on here? Anything will help and will be much appreciated! Thanks.
mrjoncrowe
0
Newbie Poster
Recommended Answers
Jump to Post$term = $_POST['searchterm']; $dat = mysql_query("SELECT * FROM tbl WHERE colum LIKE '%$term'") or die(mysql_error()); if($data = mysql_fetch_array($dat)) echo mysql_num_rows($dat)." result(s) found"; do{ // display results with echo } while($data = mysql_fetch_array($dat)); } else{ echo "Sorry no results found :("; }
Jump to Postset the form action to search.php and set the id of search field to searchterm.
<?php //connect your server mysql_connect("localhost","username","password"); //connect your db mysql_select_db("database"); $term = $_POST['searchterm']; //in the below line replace tbl with the table name and the column with the column name(you want to search) …
All 5 Replies
architact
25
Junior Poster
mrjoncrowe
0
Newbie Poster
architact
25
Junior Poster
mrjoncrowe
0
Newbie Poster
architact
25
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.