Hi I am new to web technology (Well not advanced). I am trying to build an online store (computer hardware) with mysql and PHP, I am wondering how to add a search functionality (not google's). I am planning to make a search bar where visitors can enter key word or key words for search. The search for these key words should span many tables with totally different content. I know about SQL syntax, I have a good understanding of REGEXPs, I am good with indexes and views... The only thing I want is guidance, a general idea.
-
http://www.mysqltutorial.org/mysql-full-text-search.aspx – cptnk Jan 17 '14 at 09:05
-
1This is not a place where guys will write a code for you. You must show the effort(What you've searched to find all these , have you googled ?)?? – Kaushik Jan 17 '14 at 09:08
-
Look into [jQuery AJAX](http://api.jquery.com/jquery.ajax/) and make use of MySQL wildcards. EG _LIKE "%searchterm%"_ – MisterBla Jan 17 '14 at 09:10
-
You can also find these links useful http://www.tutorialspoint.com/mysql/mysql-like-clause.htm http://stackoverflow.com/questions/583336/how-do-i-create-a-pdo-parameterized-query-with-a-like-statement – Kaushik Jan 17 '14 at 09:12
-
1Yes kk12391 I know this is not the place to look for people to write my code. AND I'm not looking for that either. I know for sure that this is a place where people can understand questions though you made me think about it twice and reconsider my opinion. – user3134422 Jan 17 '14 at 09:15
-
@user3134422 What you should do then is get enough rep and ask in the chats. Asking on SO like this will not get you any further. – MisterBla Jan 17 '14 at 09:19
2 Answers
you should first design your database. then make website design and program it in PHP.
as far as search functionality concerns you should make something like that,
eg. database and tables and their columns etc..
for example, if you have one table named hardwares
+--id---+---Name----+---Cost----+-Warrenty--+
+-------+-----------+-----------+-----------+
| 1 |hardware1 | 2000 | 2 |
| 2 |hardware2 | 5000 | 1 |
| 3 |hardware3 | 5000 | 3 |
+-------+-----------+-----------+-----------+
then in coding part of the website there will be query fired something like that,
select * from hardwares where Name LIKE '%$search_input%`
here, the search input is taken from the user and this query will result the particular hardwares' information and then from the results you can get ID
of that hardware which is already stored in that table.
from that ID
, you can make a page that will accessed by a particular query for example,
http://www.yourwebsite.com/hardwares.php?id=2
this page will load that particular hardwares' page and it will have all the information regarding to that hardware.

- 3,000
- 4
- 39
- 66
-
thr is not any rocket science to develop such kind of websites, but to develop from scratch you've to learn step by step and increase knowledge and use it in your work. – Bhavesh G Jan 17 '14 at 09:36
Search from catalog items - this is search for database.
MySQL code
SELECT nameItem FROM catalogItem WHERE `nameItem` LIKE '%search phrase%' OR `descriptionItem` LIKE '%search phrase%'
This is the simplest example.
A architecture of search I would do with caching results in a separate table.
PS See how to implement search in popular CMS

- 100
- 2
- 7