06-05-2013, 08:14 PM | #1 |
Registered User
Join Date: Dec 2012
Posts: 25
|
How to program a website search with PHP?
<form action="something.php" method="post">
<input type="text" id="search" name="search /> <input type="submit" value="submit" /> </form> 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. |
10-16-2013, 09:01 AM | #2 |
Registered User
Join Date: Oct 2013
Posts: 15
|
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. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
List of Search Engines | rajivwebads | Search Engine Optimization | 107 | 05-11-2022 11:25 PM |
Talk about search engine optimization and search engine website of a SEO must pay att | ruixuan | Search Engine Optimization | 9 | 07-06-2018 03:25 AM |
Secrete for seo | alina albert | Search Engine Optimization | 87 | 03-11-2018 05:47 AM |
Search engine optimization (SEO) | alina albert | Search Engine Optimization | 36 | 05-09-2017 10:32 PM |
Tips For Improving Your Site’s Search Engine Positioning | theshawnchin | Search Engine Optimization | 6 | 04-18-2014 02:27 AM |