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";
so....you want us to write it for you instead of you asking us how ot do it or citing a specific problem? if the course exists, you want us to display all student information? why is $studentid=$_POST['coursenumber'] ? wouldn't that set the student id equivalent to the course number then, when you actually want to get the student id based off the course number? first step is to connect to your db mysql_connect($dbtype,$dbusername,$dbpassword); //dbtype usually localhost mysql_select_db($db); // select db //now you need to check if course is there $result=mysql_query("SELECT * from course WHERE course_num='$coursenumber'"); $rcheck=mysql_num_rows($result) // this will see if your course numb exists //if it does exist, then you just pull data from grade where //course = $coursenumber and pull data from student where its equal to //$stu_id //if it doesnt exist then display your error if($rcheck==0) echo "course number not found"; elseif ($rscheck!=0) { $studentid=mysql_query("SELECT stu_id FROM grade WHERE cours_num='$coursenumber'"); while ($si=$studentid) { $studentinfo=mysql_query("SELECT * from STUDENT where stu_id='$si'"); while ($info=$si) { //display it however you want } } } PHP: rudimentary, but i think it should work
What is $si and $info If they are just a variable decleration, how come they are in the while loop? Please reply.
that while loop will run until when?....I am sorry but i am not trying to be a nutcase....i am just not understanding...