sooty2006 Posted December 12, 2010 Share Posted December 12, 2010 i have placed on my online website a search for playersthis only works for usernames onlymy form consists of textbox usernameselect genderselect statusselect levelselect groupif a user selects all 4 select boxes it does't display anythingmy mysql statementmysql_query("SELECT * FROM `users` WHERE `username` LIKE '%$_POST[username]%' AND `gender` = '$_POST[gender]' AND `status` = '$_POST[status]' AND `level` = '$_POST[status]' AND `group` = '$_POST[group]'");if a user does't select a select box it will not search for it in the query!what i need is how to do this so it works selecting all the boxes i dont think the mysql statement can handle this much!any ideas? cheers. Link to comment Share on other sites More sharing options...
sooty2006 Posted December 12, 2010 Author Share Posted December 12, 2010 if anyone needs more infomation let me know if it will help solve this thanks. Link to comment Share on other sites More sharing options...
birbal Posted December 12, 2010 Share Posted December 12, 2010 $_POST[name] should be like $_POST['name'] if a user selects all 4 select boxes it does't display anythingwhat do you mean by that? is the query failing? or it is giving empty result set?if a user does't select a select box it will not search for it in the query!you can do it something like...$qry="SELECT * FROM `users` WHERE `username` LIKE '%$_POST[username]%'"if(isset($_POST['status']);$qry=$qry."AND `status` = '$_POST[status]'";//so on..with your other fieldmysql_query($qry); Link to comment Share on other sites More sharing options...
sooty2006 Posted December 12, 2010 Author Share Posted December 12, 2010 problem solved thanks for your help anyway mate! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.