swapnali_s230 Posted March 31, 2012 Share Posted March 31, 2012 I have ONE problem here. My mysql query is not working ..I don't know why? Here is that line - $query =mysql_query("SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name='COSC 3312' AND Course_Name='COSC 2430'"); If anyone knows, let me know.... Quote Link to comment Share on other sites More sharing options...
Proletarian Posted March 31, 2012 Share Posted March 31, 2012 "What" about it isn't working? Is it producing any errors? Are the variables you are using valid? Does the entry you are selecting from the database even exist? "Not working" is too vague for anyone to help you. Quote Link to comment Share on other sites More sharing options...
swapnali_s230 Posted March 31, 2012 Author Share Posted March 31, 2012 Sorry for inconvenience.. Let me explain you... $query =mysql_query("SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name='COSC 3312' AND Course_Name='COSC 2430'"); $count=mysql_num_rows($query);echo $count; If I try to echo count, it will give me 0. It is supposed to give me 1. That is how it is not working. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 31, 2012 Share Posted March 31, 2012 Course_Name='COSC 3312' AND Course_Name='COSC 2430' Course_Name cannot be two different values at the same time. You actually need to use an OR condition to select the rows where Course_Name='COSC 3312' OR Course_Name='COSC 2430'. Give the following query a try - SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND (Course_Name='COSC 3312' OR Course_Name='COSC 2430') Or even more simpler - SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name IN ('COSC 3312','COSC 2430') Quote Link to comment Share on other sites More sharing options...
swapnali_s230 Posted March 31, 2012 Author Share Posted March 31, 2012 Wow.. It worked ...Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.