PHP Form Question
I have the following code which creates a form on a webpage:
<?php
require('config.php');
$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(SQL_DB,$conn);
$sql = "SELECT member_main.member_id, firstname, lastname FROM member_main
INNER JOIN member_event_link ON member_event_link.member_id = member_main.member_id
WHERE member_event_link.event_id='4'";
echo "<table border='1' width='70%'><form action='http://www.geft-online.org/testentry.php' method='POST'>
<tr><th align='center'>Member</th><th align='center'>Number Correct</th><th align='center'>
Elapsed Time</th></tr>";
$result=mysql_query($sql) or die(mysql_error());
while ($rows = mysql_fetch_array($result)) {
$member_id = $rows['member_id'];
$firstname = $rows['firstname'];
$lastname = $rows['lastname'];
$fullname = $firstname . " " . $lastname;
echo "<tr>
<td>$fullname</td>
<td><input type='text' name='correct$member_id'></td>
<td><input type='text' name='et$member_id'></td>
</tr>";}
echo "<tr><td colspan='3' align='center'><input type='submit' value='submit'>
</td></tr></from></table>";
?>
This code generates a line on a form for each of the rows returned in the query.
I'm running into difficulty creating the page that will enter the information in the form into my database.
I know all I need to do is create a string that would fit into the VALUES section of an INSERT sql statement. I'm just a little confused as how to do this with a variable number of lines on the form. Any suggestions would be greatly appreciated.
Thank you!
|