gammaman Posted April 26, 2008 Share Posted April 26, 2008 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 More sharing options...
AndyB Posted April 26, 2008 Share Posted April 26, 2008 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. Yes, change name='grd' to name='grd[]' and your input values will be in an array named grd Link to comment https://forums.phpfreaks.com/topic/103068-issues-with-form/#findComment-527922 Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 there is no action defined here, which is why it goes to itself: echo "<form action = '' type = 'hidden' method='post'>"; Link to comment https://forums.phpfreaks.com/topic/103068-issues-with-form/#findComment-527923 Share on other sites More sharing options...
gammaman Posted April 26, 2008 Author Share Posted April 26, 2008 Yeah I realize that, I took it out, I thought at one point I would need a hidden form on this page but I don't. I just need away to store all of the inputs using the same input name so that the next page can retrieve all of the values. Link to comment https://forums.phpfreaks.com/topic/103068-issues-with-form/#findComment-527927 Share on other sites More sharing options...
gammaman Posted April 26, 2008 Author Share Posted April 26, 2008 Yes, change name='grd' to name='grd[]' and your input values will be in an array named grd How do I retrieve them on the next page because I tried to ways and neither work. I tried $var=$_POST['grd[]']; and $var=$_POST['grd']; Link to comment https://forums.phpfreaks.com/topic/103068-issues-with-form/#findComment-527930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.