Jump to content

issues with form


gammaman

Recommended Posts

Ok what this code does is check to see what courses a student is registered in and displays them in a table.  If they have a grade for the course it is also displayed.  If not I have an input box next to the course so that a grade could be entered.  Problem is when I click submit, instead of going to the page from the "action" on the form, it just reloads the current page and all I see is one table row instead of seeing the number of rows for which the student has courses.  I think it may be because I am trying to submit multiple values using the same input name.  If it is possible to send the information using the same input name, but stored in an array, that might clear things up.  What do you think.

 


<?php

  $conn=mysql_connect("localhost","fierm","13183");

  if(!$conn){
    echo "failed";
}else{

   mysql_select_db(fierm);

   $StudentID = $_POST['id'];

   session_start();
   $_SESSION['admin']['admins'];

   $_SESSION['admin']['adminpass'];
   
   echo "<form action = '' type = 'hidden' method='post'>";
   
   echo '<table border="1">';
   echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; 

   $result=mysql_query("select CourseID,CourseName,Grade From Rcourse
                  WHERE StudentID='$StudentID'");

   $cou=mysql_num_rows($result);
   


   if ($cou==0){
      echo "Not in Any Courses";
   }else{
   
   
   while ($row=mysql_fetch_array($result))
   {

     $CourseID= $row['CourseID'];          
     $grade = $row['Grade'];
     $Course=$row['CourseName'];
   
         
     if (($grade) < "A"){
     $value =  "<form action='updateGrades.php'  method= 'post'>
                 <input name = 'grd' size='5' type='text' />";
                
             
     	     }else{ 
          	$value = "$grade";
           
     } #end if...else
       echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>";
       
       
   } #end while
   
    // "</form>";
   } #if...else
     
   echo "</table>";
     echo '<input name="submit" type="submit" value="submit" />';
   echo "</form>";   
   echo "<b>Return to Student Page</b>";
   echo "<a href = \"student.php\">Return to Student Page</a>";

   


}
?>

Link to comment
https://forums.phpfreaks.com/topic/103068-issues-with-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.