Jump to content

help putting input box within table cell.


gammaman

Recommended Posts

Is it even possible to put an input box within a table cell.  I am trying to do something like this but no luck yet.  Here is a portion of the code.

 

while ($row=mysql_fetch_array($result))
   {

     $CourseID= $row['CourseID'];          
     $grade = $row['Grade'];
     $Course=$row['CourseName'];
     
         
     if (($grade) == " "){
     $value = echo '<form action="updateGrades.php" method= "post">' .
                 echo  '<input name = "grd" type="text" />'; 
     	     }else{ 
          	$value = "$grade";
           
     } #end if...else
       echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>";
   } #end while

It works now I forgot to reload the page after the last upload.  Now the problem is that I have an extra input box above the table in addition to the input box for each row that has no value in the last field.  How would I get rid of that box on top and how would I shrink the other input box.  Sorry for being a pain, and thanks for everyones help.

OK I got that part working, now I still need to figure out why I have an input box before the table even starts.  It is literally just above the table ouside the border

 


<?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'];

   $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{
   
   echo '<table border="1">';
   echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>"; 
   while ($row=mysql_fetch_array($result))
   {

     $CourseID= $row['CourseID'];          
     $grade = $row['Grade'];
     $Course=$row['CourseName'];
   
         
     if (($grade) == ""){
     $value =  "<form action='updateGrades.php'  method= 'post'>
                 <input name = 'grd' size='2px' type='text' />"; 
                echo "$value";
                echo "</form>";
     	     }else{ 
          	$value = "$grade";
           
     } #end if...else
       echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>";
   } #end while
   } #if...else
  // echo "</form>";
   echo "</table>";

   echo "<b>Return to Student Page</b>";
   echo "<a href = \"student.php\">Return to Student Page</a>";

   


}
?>

The two input boxes are still above the table but they are closer together now.


<?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 '<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) == ""){
     $value =  "<form action='updateGrades.php'  method= 'post'>
                 <input name = 'grd' size='5' type='text' />"; 
                echo "$value";
                
     	     }else{ 
          	$value = "$grade";
           
     } #end if...else
       echo "<tr><td>$CourseID</td><td>$Course</td><td>$value</td></tr>";
       
   } #end while
     
   } #if...else
     
   echo "</table>";
   echo "</form>";
   echo "<b>Return to Student Page</b>";
   echo "<a href = \"student.php\">Return to Student Page</a>";

   


}
?>

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.