Alicia Posted March 9, 2009 Share Posted March 9, 2009 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 More sharing options...
jmurch Posted March 9, 2009 Share Posted March 9, 2009 How about: select * from table where name = $name OR class = $class OR gender = $gender order by $sorting method Link to comment https://forums.phpfreaks.com/topic/148644-mutiple-fields-in-search-box/#findComment-780659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.