kev wood Posted April 3, 2009 Share Posted April 3, 2009 i am trying to select only a few values from a column depending on the selection from a drop down menu. what i want to be able to do is have the user select a title from a drop down menu which is populated from a mysql db. then once the selection has been made the user the goes to the next page where all the people's email address will be displayed who registered interest in the chosen subject from the drop down menu. at the minute my code is not exactly write as it is looking for a column with the value from the drop down menu. here is what i have so far $query="SELECT id, title FROM training WHERE 'housing'=$a"; what this line should be doing (which it does not) is select the id and title from the training table but only select the the rows which have the value of a in the housing column. hope i have made myself clear if not i will try to explain better. Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/ Share on other sites More sharing options...
Mark Baker Posted April 3, 2009 Share Posted April 3, 2009 Quote the value (assuming the column is a varchar), not the column name: $query="SELECT id, title FROM training WHERE housing='$a'"; Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/#findComment-800148 Share on other sites More sharing options...
kev wood Posted April 3, 2009 Author Share Posted April 3, 2009 thanks for the reply. yes the column is set to varchar. that is working fine now. Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/#findComment-800154 Share on other sites More sharing options...
kev wood Posted April 3, 2009 Author Share Posted April 3, 2009 is possible to the following $query="SELECT id, title FROM training WHERE option1, option2, option3 = '$a'"; Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/#findComment-800162 Share on other sites More sharing options...
Mark Baker Posted April 3, 2009 Share Posted April 3, 2009 is possible to the following I assume you mean: $query="SELECT id, title FROM training WHERE option1 = '$a' OR option2 = '$a' OR option3 = '$a'"; Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/#findComment-800173 Share on other sites More sharing options...
kev wood Posted April 3, 2009 Author Share Posted April 3, 2009 yes thanks for the reply. i didnt need to do it in that way in the end. i needed it to work so i could see which option people had selected for the 1, 2, and 3 and not put all the email address in the one box. thanks for the reply anyway. Link to comment https://forums.phpfreaks.com/topic/152353-solved-select-from-where-problem/#findComment-800194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.