key Roster_Number Race_Number Points
1 17 9 44
2 20 29 43
3 6 29 38
4 4 29 35
5 10 29 35
6 15 29 36
7 18 29 31
8 2 29 27
I am using this data to display points totals and that works great, I am trying to make an easier way to insert the data, Here is my insert.php and admin.php. I really appreciate the help. Please let me know if you need anything else.
insert.php
Code: Select all
<?php
error_reporting(E_ALL);
var_dump($_POST);
mysql_connect("mysql", "**********", "*********") or die ('Could not connect: ' . mysql_error());
mysql_select_db("RMDCRA");
if(count($_POST) > 0){
$pointsarray = $_POST['pointsarray'];
array_map('intval',$pointsarray);
$pointsarray = implode(',',$pointsarray);
mysql_query("INSERT INTO Results IN ($pointsarray)") or trigger_error(mysql_error(),E_USER_ERROR);
$updated=TRUE;
?>
Code: Select all
<?php
error_reporting(E_ALL);
?>
<html>
<body>
<?php include("../includes/Header.html"); ?>
<?php include("../includes/conn.php"); ?>
<form action="insert.php" method="post">
<?php
if($updated===TRUE)
{echo '<div>Points Updated</div>';
}
?>
<table border="1" cellspacing="0" cellpadding="0" align="center">
<tr>
<th>
Race Date:
</th>
<td colspan="2">
<?php
$query="SELECT Race_Number, Date FROM Schedule where PointsAwarded not like '*' ORDER BY Date";
$result2 = mysql_query($query) or die("Error executing:<br>$query<br>" . mysql_error() );
echo "<select name=\"Race_Number\">";
echo "<option></option>";
while ($row=mysql_fetch_assoc($result2)) {
echo "<option value=\"{$row['Race_Number']}\">{$row['Date']}</option>";
}
echo "</select>";
?>
<tr>
<th>Roster Number</th>
<th>Car Number</th>
<th>Points</th>
</tr>
<?php
$sql = "SELECT Roster_Number, Car_Number FROM Roster";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
while(list($Roster_Number, $Car_Number)=mysql_fetch_row($result)){
echo '<tr><td>'.$Roster_Number.'</td><td>'.$Car_Number.'</td>
<td><input style="border: 1px solid #FFFFFF type="text" name ="pointsarray[]"/></td>
</tr>'."\n";
}
?>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit Points" /></td>
</tr>
</table>
</form>
</body>
</html>