| | |
Creating a search which collects data from MYSQL Database and displays.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
Hi There,
I have had a look on the internet but not really been able to find the correct thing i'm looking for very easily, or at least not very well/easily explained.
I am trying to create a Search Form for my website which has 2 fields.
1) A Postcode Field.
and 2) a Category drop down Menu
When the user clicks search the search should enter a MYSQL table on my database and find the postcode entered and the selected category fields and display the results along with additonal information such as address and telephone number.
For instance.
I search L21 2AG
and pick the Category: Cafe
The search then brings up 3 results (for example)
1) LS1 2AG - Cafe - 12 Main Street, Leeds - 01313135432
2) LS1 2AG - Cafe - 16 The Green, Leeds - 01313352124
3) LS1 2AG - Cafe - 90 Grove Street, Leeds - 013131242342
Anyone got any idea's.
Any code I can use, and websites for tutorials or something maybe.
I have a basic idea of the code Im going to require, not not very detailied idea.
Thankyou very much, I do hope you can help me.
Also I hope this was posted in the correct post, I've used this website numerous times before but only just created an account and posted.
Cheers,
Jordan
EDIT: Also I understand I may need a search.php file to proccess this? Cheers
I have had a look on the internet but not really been able to find the correct thing i'm looking for very easily, or at least not very well/easily explained.
I am trying to create a Search Form for my website which has 2 fields.
1) A Postcode Field.
and 2) a Category drop down Menu
When the user clicks search the search should enter a MYSQL table on my database and find the postcode entered and the selected category fields and display the results along with additonal information such as address and telephone number.
For instance.
I search L21 2AG
and pick the Category: Cafe
The search then brings up 3 results (for example)
1) LS1 2AG - Cafe - 12 Main Street, Leeds - 01313135432
2) LS1 2AG - Cafe - 16 The Green, Leeds - 01313352124
3) LS1 2AG - Cafe - 90 Grove Street, Leeds - 013131242342
Anyone got any idea's.
Any code I can use, and websites for tutorials or something maybe.
I have a basic idea of the code Im going to require, not not very detailied idea.
Thankyou very much, I do hope you can help me.
Also I hope this was posted in the correct post, I've used this website numerous times before but only just created an account and posted.
Cheers,
Jordan
EDIT: Also I understand I may need a search.php file to proccess this? Cheers
Last edited by J.M; 30 Days Ago at 5:59 pm.
•
•
Join Date: Oct 2009
Posts: 35
Reputation:
Solved Threads: 5
0
#2 30 Days Ago
•
•
•
•
Hi There,
I have had a look on the internet but not really been able to find the correct thing i'm looking for very easily, or at least not very well/easily explained.
I am trying to create a Search Form for my website which has 2 fields.
1) A Postcode Field.
and 2) a Category drop down Menu
When the user clicks search the search should enter a MYSQL table on my database and find the postcode entered and the selected category fields and display the results along with additonal information such as address and telephone number.
For instance.
I search L21 2AG
and pick the Category: Cafe
The search then brings up 3 results (for example)
1) LS1 2AG - Cafe - 12 Main Street, Leeds - 01313135432
2) LS1 2AG - Cafe - 16 The Green, Leeds - 01313352124
3) LS1 2AG - Cafe - 90 Grove Street, Leeds - 013131242342
Anyone got any idea's.
Any code I can use, and websites for tutorials or something maybe.
I have a basic idea of the code Im going to require, not not very detailied idea.
Thankyou very much, I do hope you can help me.
Also I hope this was posted in the correct post, I've used this website numerous times before but only just created an account and posted.
Cheers,
Jordan
EDIT: Also I understand I may need a search.php file to proccess this? Cheers
In the search.php, the first thing u need to do is to retrieve the posted info.
for example,
PHP Syntax (Toggle Plain Text)
$postCode = $_POST['search']; $cat = $_POST['cat'];
If you don't know how to do this, I suggest you to take this tutorial at http://www.tizag.com/mysqlTutorial/mysqlquery.php. Have a skim thru all the links.
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#3 30 Days Ago
Hi There,
Thanks Kekkaishi, I have more of an understanding now.
I've also been having a look at that link you supplied.
Could you, or possibly someone supply me with the code which I will be able to query the database and SELECT the information like you talked about, and then display the data?
Also what code would I need for the search form and for it too use the POST action to search.php?
I have done theese sort of things before, but it was long ago and I have forgotton theese things, but I do have a general idea of what you are talking about so not completey clueless haha
..
If anyone could help me with the above it would be greatly appreicated.
Thanks again Kekakishi and Ill have a more indepth look at that link you supplied me, it does look very useful from what I can see!
Thankyou,
J.M
Thanks Kekkaishi, I have more of an understanding now.
I've also been having a look at that link you supplied.
Could you, or possibly someone supply me with the code which I will be able to query the database and SELECT the information like you talked about, and then display the data?
Also what code would I need for the search form and for it too use the POST action to search.php?
I have done theese sort of things before, but it was long ago and I have forgotton theese things, but I do have a general idea of what you are talking about so not completey clueless haha
..If anyone could help me with the above it would be greatly appreicated.
Thanks again Kekakishi and Ill have a more indepth look at that link you supplied me, it does look very useful from what I can see!
Thankyou,
J.M
0
#4 30 Days Ago
•
•
•
•
ok, lets say u name search field 'search' and the drop-down menu for 'cat'. and make the form POST all info to search.php (method POST action search.php).
In the search.php, the first thing u need to do is to retrieve the posted info.
for example,Having done that, u need to query the database. you may want to SELECT all from your postcodestable WHERE postCode = $postCode AND category = $cat and display all info.PHP Syntax (Toggle Plain Text)
$postCode = $_POST['search']; $cat = $_POST['cat'];
If you don't know how to do this, I suggest you to take this tutorial at http://www.tizag.com/mysqlTutorial/mysqlquery.php. Have a skim thru all the links.
Also, with Postcodes people will not always enter them in the saem format, for example, postcodes may be entered in multiple ways:
AB123CD
AB 123 CD
AB123 CD
AB12 3CD
So I would suggest removing spaces from the POST data before querying and also having the values in the database with no spaces, or use a replace command in the query to remove them for the search. Otherwise there is a chance that you may not get results when you should.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
![]() |
Similar Threads
- Inserting data to mysql database using php created form (MySQL)
- insert data into the mysql database using ajax (JavaScript / DHTML / AJAX)
- How to Insert/Edit data from TAG SELECT HTML Form to MySQL Database? (PHP)
- Help! my script couldn't submit form data to mysql database (PHP)
- how to update data in mysql database using jsp (JSP)
- How to import excel file data to mysql database (ASP.NET)
- MSSQL - MySql Database Connectivity (MS SQL)
- retrieving a single cell of data from a MySQL database (PHP)
- search engine (PHP)
- Php code confusion. Not sure how to describe (PHP)
Other Threads in the PHP Forum
- Previous Thread: how to update and delete data using mysql query
- Next Thread: Get url of top frame..
| Thread Tools | Search this Thread |
access adsense adult advanced advertising ajax api apple array bing business c# cms code copyright crime cuil data database dataloss development display drive dropdownlist earth email engine europe facebook files flash form forms google hack hard hardware hitachi image include internet iphone java javascript jquery kaspersky lamp legal link linux login malware marketing mcafee menu microsoft mobile module msn multiple mysql news oracle php post privacy programming query radio revenue rss script search searchengine security select seo server sex sms soap software spyware sql storage survey table terabyte tutorial twitter universe upload video videosearch web website wolframalpha yahoo yahoo! youtube






