Hi,
I'm trying to update multiple rows with diferent values.
The amont of values depends on the number of people created by the user.
I created some code that works for only single row.
Can anyone help? I'm not sure how to do this.
<?php
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE status SET status=%s WHERE user_id=%s",
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['hiddenField2'], "int"));
mysql_select_db($database_ConnAdmin, $ConnAdmin);
$Result1 = mysql_query($updateSQL, $ConnAdmin) or die(mysql_error());
$updateGoTo = "question.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_ConnAdmin, $ConnAdmin);
$query_Recordset1 = "SELECT * FROM status";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $ConnAdmin) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
?>
//
<div id="mainContent">
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="50%" border="1" cellspacing="5" cellpadding="5">
<th>
<td>Status</td>
<td></td>
<td>User Id</td>
</th>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['status_id']; ?></td>
<td><select name="status" id="status">
<option value="Great">Great</option>
<option value="Good">Good</option>
<option value="Bad">Bad</option>
</select>
</td>
<td><?php echo $row_Recordset1['status']; ?></td>
<td><?php echo $row_Recordset1['user_id']; ?>
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_Recordset1['status_id']; ?>" />
<input name="hiddenField2" type="hidden" id="hiddenField2" value="<?php echo $row_Recordset1['user_id']; ?>" /></td>
<td><?php echo $row_Recordset1['status']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p>
<input type="submit" name="btn_1" id="btn_1" value="Submit" />
</p>
<input type="hidden" name="MM_update" value="form1" />
</form>
<h1> </h1>
<!-- end #mainContent --></div>