Hello
I’m learning PHP by problem solving and I’m up against another problem. I want the user to enter a ID number which will display all records in a DB assigned to that ID. That part is working fine. The problem is that I’m getting all the records with a submit button under each record and it’s not updating. Is the problem in this code or in my form processing script? I would like it to display all records in the table and be able to modify any of those and click submit and have all records updated. Thank you very much for taking a look and leading me in the right direction
//$results variable = the results of the query
$results = mysql_query($sql)
or die ("Stopped at the mysql_query");
$num=mysql_num_rows($results);
while($row = mysql_fetch_array($results));
$sql1=mysql_query("SELECT sid FROM volunteer WHERE sid='$sid'");
if (mysql_num_rows($sql1)==0 || mysql_num_rows($sql1)<1)
{ die ("Sorry, the ID you submitted is not present in our database. Please hit your browser's back button and reenter your student's ID.");
}
else;
$i=0;
while ($i < $num) {
$id=mysql_result($results,$i,"id");
$sid=mysql_result($results,$i,"sid");
$wperson=mysql_result($results,$i,"wperson");
$student=mysql_result($results,$i,"student");
$hours1=mysql_result($results,$i,"hours1");
$hours2=mysql_result($results,$i,"hours2");
$hours3=mysql_result($results,$i,"hours3");
$hours4=mysql_result($results,$i,"hours4");
$hours5=mysql_result($results,$i,"hours5");
$hours6=mysql_result($results,$i,"hours6");
?>
<form action="volchanged.php" method="post">
<table border='1'>
<th>Student ID</th>
<th>Person Working</th>
<th>March 1st</th>
<th>March 2nd</th>
<th>March 15th</th>
<th>March 16th</th>
<th>April 5th</th>
<th>April 10th</th>
<th>April 11th</th>
<tr>
<td><input type="text" name="ud_sid" value="<? echo "$sid"?>"></td>
<td><input type="text" name="ud_wperson" value="<? echo "$wperson"?>"></td>
<td><input type="text" name="ud_student" value="<? echo "$student"?>"></td>
<td><input type="text" name="ud_hours1" value="<? echo "$hours1"?>"></td>
<td><input type="text" name="ud_hours2" value="<? echo "$hours2"?>"></td>
<td><input type="text" name="ud_hours3" value="<? echo "$hours3"?>"></td>
<td><input type="text" name="ud_hours4" value="<? echo "$hours4"?>"></td>
<td><input type="text" name="ud_hours5 value="<? echo "$hours5"?>"></td>
<td><input type="text" name="ud_hours6" value="<? echo "$hours6"?>"></td></tr>
<BR>
</table>
<input type="Submit" value="Submit">
</form>
<?
++$i;
}
?>
</BODY>
</HTML>