Here is a link to what I'm trying to do.
http://www.angelfire.com/dc/blobbby/insert_stats.html
I'll list my code below.
Here is the code for the html page.
<head>
<title>Stat insertion test page</title>
</head>
<body>
<h1>Stat insertion test page</h1>
<form action="insert_stats.php" method="post">
<table border=0 width="952" height="230">
<tr>
<td width="112">Number</td>
<td width="207"> Name<br>
</td>
<td width="175">Yards</td>
<td width="139">Rushing TD</td>
</tr>
<tr>
<td width="112">
<input type=text name=number[] maxlength=3 size=5>
</td>
<td width="207">
<input type=text name=name[] maxlength=30 size=30>
<br>
</td>
<td width="175">
<input type=text name=yards[] maxlength=60 size=30>
</td>
<td width="139">
<input type=text name=rtd[] maxlength=7 size=7>
</td>
</tr>
<tr>
<td width="112">
<input type=text name=number[] maxlength=3 size=5>
</td>
<td width="207">
<input type=text name=name[] maxlength=30 size=30>
<br>
</td>
<td width="175">
<input type=text name=yards[] maxlength=60 size=30>
</td>
<td width="139">
<input type=text name=rtd[] maxlength=7 size=7>
</td>
</tr>
<tr>
<td colspan=4>
<input type=submit value="Register" name="submit">
</td>
</tr>
</table>
</form>
</body>
Here is the code for my php page.
<head>
<title>Stat insertion test results</title>
</head>
<body>
<p><font face="Geneva, Arial, Helvetica, san-serif" size="4">Stat insertion test
results</font></p>
<?
$x = 0;
while($x < 2){
if (!$number[$x] || !$name[$x] || !$yards[$x] || !$rtd[$x])
{
echo "You have not entered all the required details.<br>"
."Please go back and try again.";
exit;
}
$number = doubleval($number[$x]);
$name = addslashes($name[$x]);
$yards = doubleval($yards[$x]);
$rtd = doubleval($rtd[$x]);
@ $db = mysql_pconnect("localhost", "root");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("rush");
$query = "insert into players values ('".NULL."', '".$number."', '".$name."', '".$yards."', '".$rtd."')";
$result = mysql_query($query);
$x++;
}
if ($result)
echo mysql_affected_rows()." player stats inserted into database.";
?>
</body>
My first if statement always returns false and echos. "You have not entered all the required details" The code works perfect when I use only 1 row and remove the [] from the variables.
I've been stuck on this for a while and am getting very frustrated. I've searched the forum and can't seem to find a thread that applies to my prob. If anyone sees any bugs in my code or has any suggestions please let me know. Thanks