Jump to content

Multiple Search- Query Question


xXMaverickXx

Recommended Posts

Hey everyone, I'm new here but I figured I'd give it a shot. I'm working on a project where I have a database with entries I want to be able to search through.

 

Right now I have 3 text fields in a form "name" "age" and "gender"

 

I am using " if " statements to check if there is data in the field then run the query checking for that info ' WHERE name = "$name" '

then 2 more for age and gender. Obviously this then runs 3 queries that have 3 outputs.

 

I then tried ' WHERE name = "$name" and age = "$age" and gender = "$gender" '

I've also tried ' WHERE name = "$name" or age = "$age" '

 

But none give the result I'm looking for.

 

I want to be able to put a name in hit search and the results show....while leaving age and gender blank.

But when I put in a name and age it checks for entries that match both. I'm sure it's something way easier then I'm thinking it is and I'm just missing the obvious but any help you guys can share it would be awesome!

 

 

Link to comment
https://forums.phpfreaks.com/topic/106351-multiple-search-query-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.