Mods: Maybe you could move this to the Newbie forum for me? Sorry bout misplaced post.
I am attempting to have a form consisting of a looped recordset update multiple records on submission.
It is not working properly, it deletes the values from the table, and doesnt insert anything.... Any ideas?
Here is my update code:
if ((isset($HTTP_POST_VARS["update"])) && ($HTTP_POST_VARS["update"] == "form1")) {
$i=1;
while ($i < $totalRows_NavigationEdit) {
$query_string = sprintf("UPDATE Navigation SET linktext='$linktext', url='$url', inNav='$inNav' WHERE id='$i'");
mysql_select_db($database_MySQL, $MySQL);
$Result1 = mysql_query($query_string, $MySQL) or die(mysql_error());
$i++;
}
Here is the form:
<form name="form1" method="post" action="<?php echo $editFormAction; ?>">
<input name="index" type="hidden" value="1">
<?php do { ?>
<?php / Set a unique variable for each returned row in order to update the records /
$RecID = $row_NavigationEdit['id']; ?>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="146">Linktext:</td>
<td width="254"><input name="hidRecID<?php echo $RecID ?>" type="hidden"value="<?php echo $RecID ?>"> <?php echo $RecID; ?> <input name="linktext<?php echo $RecID; ?>" type="text" id="lintext<?php echo $RecID; ?>" value="<?php echo $row_NavigationEdit['linktext']; ?>"></td>
</tr>
<tr>
<td>URL:</td>
<td><input name="url<?php echo $RecID; ?>" type="text" id="url<?php echo $RecID; ?>" value="<?php echo $row_NavigationEdit['url']; ?>"></td>
</tr>
<tr>
<td>Footer Linktext:</td>
<td><input name="footertext<?php echo $RecID; ?>" type="text" id="footertext<?php echo $RecID; ?>" value="<?php echo $row_NavigationEdit['footertext']; ?>"></td>
</tr>
<tr>
<td>In Navigation?</td>
<td><input <?php if (!(strcmp($row_NavigationEdit['inNav'],"yes"))) {echo "CHECKED";} ?> type="radio" name="inNav<?php echo $RecID; ?>" value="Yes">
Yes
<input <?php if (!(strcmp($row_NavigationEdit['inNav'],"no"))) {echo "CHECKED";} ?> type="radio" name="inNav<?php echo $RecID; ?>" value="No">
No</td>
</tr>
<tr>
<td>Order:</td>
<td><input name="order<?php echo $RecID; ?>" type="text" value="<?php echo $row_NavigationEdit['order']; ?>"></td>
</tr>
<tr>
<td colspan="2"><hr size="1" noshade></td>
</tr>
</table>
<?php } while ($row_NavigationEdit = mysql_fetch_assoc($NavigationEdit)); ?>
<input type="hidden" name="update" value="form1">
<input type="submit" name="Submit" value="Submit">
</form>