BelowZero Posted March 12, 2011 Share Posted March 12, 2011 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 https://forums.phpfreaks.com/topic/230385-cant-post-to-database/ Share on other sites More sharing options...
Pikachu2000 Posted March 12, 2011 Share Posted March 12, 2011 What happens, anything at all? Link to comment https://forums.phpfreaks.com/topic/230385-cant-post-to-database/#findComment-1186461 Share on other sites More sharing options...
BelowZero Posted March 12, 2011 Author Share Posted March 12, 2011 It runs as if everything worked, then returns me to my "admin_main_update.php" page. (I removed the error checking since no errors are returned.) Link to comment https://forums.phpfreaks.com/topic/230385-cant-post-to-database/#findComment-1186464 Share on other sites More sharing options...
creata.physics Posted March 12, 2011 Share Posted March 12, 2011 Well, you're redirecting the user before the rest of the code can execute, have you tried running it without that header() function? Just to make sure the row inserts into the db? If it works after that you should put the header() code after the insert code has processed. Link to comment https://forums.phpfreaks.com/topic/230385-cant-post-to-database/#findComment-1186501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.