Hi,
I need PHP code to help me with the following stuff:
1. I have a MySQL table with addresses split into 4 fields.
2. I need a search functionality which can search the MySQL table in 2 of the fields, fetch all the relative addresses and display them in an HTML table.
3. I'll have only one field in which I can enter the search keyword.
Thanks in advance,
Regards,
Ravi.
Search from MySQL Table and display result in HTML Table
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Search from MySQL Table and display result in HTML Table
For #2, you should look at the examples in the PHP manual for the query() functions for the database connector you are using (e.g. PDO).
For #3, you can search multiple fields with a search term in SQL:
For #3, you can search multiple fields with a search term in SQL:
Code: Select all
$search = $db->escape($_POST['search']);
$result = $db->query("SELECT * FROM mytable WHERE foo='$search' OR bar='$search'");(#10850)