gammaman Posted April 24, 2008 Share Posted April 24, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/ Share on other sites More sharing options...
BlueSkyIS Posted April 24, 2008 Share Posted April 24, 2008 don't echo into a variable. $value = "<form action='updateGrades.php' method='post'><input name='grd' type='text' />"; Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526616 Share on other sites More sharing options...
gammaman Posted April 24, 2008 Author Share Posted April 24, 2008 I tried that and I still do not get any input box at all. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526630 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 After that, you have to echo the variable. His point was that you cannot echo in a variable. You assign a value to the variable, and then echo the variable. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526639 Share on other sites More sharing options...
gammaman Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks for checking but I did echo the variable and I still get nothing inside that cell. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526645 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 There may be a problem with overlapping html tags. Try closing the form in that cell, also. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526651 Share on other sites More sharing options...
gammaman Posted April 24, 2008 Author Share Posted April 24, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526657 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 To make the input box smaller, add a size="number", like you would a value="". Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526660 Share on other sites More sharing options...
gammaman Posted April 24, 2008 Author Share Posted April 24, 2008 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526667 Share on other sites More sharing options...
gammaman Posted April 25, 2008 Author Share Posted April 25, 2008 I added another record and left that field blank to see what would happen and sure enough now I have to input boxes above the table, which suggests that it is treating the space above the table as a row in the table. Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526686 Share on other sites More sharing options...
gammaman Posted April 25, 2008 Author Share Posted April 25, 2008 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/102810-help-putting-input-box-within-table-cell/#findComment-526697 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.