Jump to content

Can't post to database


BelowZero

Recommended Posts

I know this should be easy...

 

I have several text input boxes where I enter data to be sent to one column of my database.

[while($row = mysql_fetch_array( $result )) 
{
$i=1;
if ($row['game_id']='$i')
{
echo "<tr>";
echo "<td>"; echo $row['date'];
echo "</td><td>"; echo $row['team_name'];
echo "</td><td>"; echo $row['owner'];
echo "</td><td>";
echo "<input type='text' size='4' name='result[]'>";
echo "</td></tr>";

Not every box has a value so my array will end up with several numbers and several "blanks".

I echoed the array using

$result = ("$_POST[result]");

and all the values are returned as expected.

 

Now I need to UPDATE the "pt_spread" column in the database inserting all the values (even the blank values).

 

I tried the following but can't get it to actually post anything into the database.

<?php	

header("Location: admin_main_entry.php");

include("opendatabase.php");

$result = ("$_POST[result]");
foreach ($result as $spread)
{
$sql = "
UPDATE schedule 
SET pt_spread = '$spread'
WHERE week_id = '$weekID'" ;

mysql_query($sql);
}

mysql_close($con)
?>

Can anyone show me the correct way to do this? Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.