Hi , I a kinda new to all this database and PHP thing so i would appreciate your help. This forum has been a real help to me in the past. I have three tables First table named "student" stu_id f_name l_name 2nd table named "grade" stu_id cours_num grade 3rd table named "course" course_num cours_title cours_desc I have an HTML form with a text field where i need to enter cours_num Now when i click submit button it should first look into my database to check if that course number exists or not. If it does then it should display All the stu_id, f_name and l_name (remember $studentid=$_POST["coursenumber"] and also count the number of record.( relating to that cours_num that we entered from the html page) else display message "course number not found"; This is what i have but it does not work if(isset($_POST['coursenumber'])) { $coursenumber = $_POST["coursenumber"]; $connect = @mysql_connect($host, $user, $passwd) or die("connect error: " . mysql_error()); $table_name = 'course'; @mysql_select_db($database) or die('select_db error: ' . mysql_error()); print "<span class=\"c1\">$table_name Data</span><br>"; $query = "SELECT * FROM $table_name WHERE (cours_num= '$coursenumber')"; print "The query is <span class=\"c2\"> $query </span> <br>"; $results_id = @mysql_query($query, $connect) or die('query error: ' . mysql_error()); $rcheck=mysql_num_rows($results_id); { if($row = mysql_fetch_array($results_id)) { for($i=0; i<=$rcheck; $i++) { $coursenum=$row['$i']; print '<td> $coursenum</td>'; } } } } else { print '<br /><span class=\"c2\"> Connection Failed </span>'; } @mysql_close($connect) or die('close error: ' . mysql_error()); ?> </body> </html> your suggestions will be appreciated
feedback on what i gave you what have helped me narrow the problem down. also, you just tripled posted your thread. but, if your still willing to listen to my feedback, you enver checked $rcheck to be greater than 0, and its not if ($row=mysql_fetch_array($results_id)) because first off all, mysql_fetch_arrow has to be told type in the second part (thats why i recommend assoc), and its not an if check, because you are setting it so its always equal to 1