I fond some tutorial that can search one field of the table in a database,. But I would like to search the whole table.. In my table I have people's name by first name, last name, phone number etc... how can I display the whole thing as a result? For example if someone was to type only John... the results would show, John's first name, last name, phone number... etc....
desiguru
0
Junior Poster in Training
Recommended Answers
Jump to PostYou'll need to use a bit of conditional testing to build the appropriate sql string based on the submitted search terms. A simplified example shown below assumes the user can chooseto search on either firstname, lastname or both.
$fname = $_POST['firstname']; $lname = $_POST['lastname']; $where = array(); …
Jump to PostWhat are the search parameters you want to handle? Does the single search box mean that users will only search on firstname, or possibly firstname and lastname, or possibly lastname only? Or all three?
Jump to PostYou can use
SELECT * FROM tablename WHERE CONCAT(firstname,lastname,phonenr) LIKE '%$search%'
All 12 Replies
Lafinboy
4
Junior Poster
desiguru
0
Junior Poster in Training
Lafinboy
4
Junior Poster
desiguru
0
Junior Poster in Training
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
EFEXConsulting
0
Light Poster
desiguru
0
Junior Poster in Training
Dean C
0
Newbie Poster
mkhalid
0
Newbie Poster
boo_lolly
0
Light Poster
hazel_0821
0
Newbie Poster
desiguru
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.