Jump to content

Mutiple fields in search box


Alicia

Recommended Posts

Hi,

 

I am trying to create a search form with mutiple fields but it failed to work... my senior told me I should use concantenation in such form but I really have no idea what he is talking about.. can some guru advise on this ?

 

Now I have a form with the following options :

- name

- class

- gender

- subject

- sorting method

 

Currently  I am using conditional statement if else to work on this... how can I write a proper php code to accomplish this :

 

// mysql query :

select * from myclassdb where

if name is not empty, search name column in mysql with records like #name

then continue

if class is not empty and name is not empty, search record with something close to input that match the entered class and name..

and so on... i know i cant get this work by using conditional statement because there are too many conditions I can think of..

 

I seen someone did somerthng like ..

$query = mysql_query("SELECT * FROM ....

then

if($name !="") {

$query .= xxxx

}

if($class !="") {

$query .= xxxx

}

and ...

 

Can somebody please advise o this.. thanks,

 

Link to comment
https://forums.phpfreaks.com/topic/148644-mutiple-fields-in-search-box/
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.