swapnali_s230 Posted March 20, 2012 Share Posted March 20, 2012 Hi All I have been working on one program.. Its giving me output for some echo, not for other echos. I dont know why? Following is the code - if (is_array(@$_REQUEST['classes'])) { foreach($_REQUEST['classes'] as $course1) { $sql=mysql_query("SELECT Ma_CoName FROM MCourse where Ma_CoNo='$course1'"); @$course=mysql_result($sql, 0) or die('wrong query'.mysql_error()); if ($course=='ENGL 1301') echo $course; elseif ($course=='ABC 33') echo $course; elseif ($course=="VVV 34") echo $course; elseif ($course=="CCC 95") echo $course; elseif ($course=="MMM 12") echo $course; elseif ($course=="OOO 89") echo $course; elseif ($course=="CCC 75") echo $course; }} Code in bold is not giving me any output, but $course=='ENGL 1301' is giving me output. I dont know why? It is so weird..... Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 22, 2012 Share Posted March 22, 2012 get rid of the @ symbol at the start of this line: @$course=mysql_result($sql, 0) or die('wrong query'.mysql_error()); you are only pulling a single result into $cource from your mysql_query() result set that is returned from the database. You need to use a loop to itterate through the resultset array ($sql in this case) and allow you access to each row, not just the first one. Quote Link to comment Share on other sites More sharing options...
swapnali_s230 Posted March 31, 2012 Author Share Posted March 31, 2012 Thank you very much for reply.... The problem got solved...I used trim function. I have another 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'"); Quote Link to comment Share on other sites More sharing options...
fenway Posted March 31, 2012 Share Posted March 31, 2012 See here -- don't double-post next time. Quote Link to comment Share on other sites More sharing options...
swapnali_s230 Posted March 31, 2012 Author Share Posted March 31, 2012 Really sorry for inconvenience...... I had some internet problems when i posted it at first. I thought it didnt go through..... So I posted it again.... Sorry again. 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.