Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   PHP / mySQL (http://siteownersforums.com/forumdisplay.php?f=10)
-   -   How to program a website search with PHP? (http://siteownersforums.com/showthread.php?t=65373)

Jack Hard 06-05-2013 08:14 PM

How to program a website search with PHP?
 




In your PHP script, you'd just do something similar to mysql %like%. The % specifies a wildcard so that if the name of what you're searching for is "over" then it will return "stackoverflow". Just be sure to escape your query. After you do your query (which I won't write out because it will be different if you're using procedural vs. OOP vs. a framework) then you can do a while() loop to display all of your results

$qry = "select * from my_table where name like %".$this->real_escape_string($_POST['search'])." order by name";

If you give me some more info about your DB, your programming style, I can help you more. I'd definitely check out some tutorials though as this is a VERY simple approach to search.

Ranjan123 10-16-2013 09:01 AM

nice for one word search,

if the search term is more than one word and dont return results, then you can use "OR" with the words.


All times are GMT -7. The time now is 09:29 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.