Search multiple fields in a single table
I am trying to create a search facility for my website and need to be able to search multiple fields in a single table in MySQL, I am using dreamweaver, and my PHP and SQL knowledge is minimal, I donít have a problem being able to search a single field in the database and displaying the results as dreamweaver generates the code for me.
The table I am trying to create the search for is called LEWISHAM and the fields within the table I need to search are; towna, townb, townc, postcodea, postcodeb, postcodec
If someone could please help me or point me in the right direction where I could learn more about searches or give me some tips to help that would be fantastic
Beware: Crazy Scientist
something like this:
However... I wonder WHY you have a towna and townb. Sounds like poor database design to me..
$query = "
select towna, townb, townc, postcodea, postcodeb, postcodec
postcodea = "$postcodea")
(townb = "$townb"
and postcodea = "$postcodea")";
Php 4.* to 5.*. A small step for programmers. But a leap for me!
You can keep adding or statements to search the other fields. Let me know if you need anything else. I am good at doing this but not at explaining it.
$query = "select * from LEWISHAM where towna LIKE '%".$_GET['form_value']."%' or townb LIKE '%".$_GET['form_value']."%'";
hello im new here.. Im trying to do search for multiple fields can you please help me?
Frido, please try not to resurrect dead threads, this one was over 5 years old!
If you have a question, start a new thread. However, seeing that your question seems to be exactly the same, you could just try what has been posted as the answer for the OP.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread