How to update the checked rows with multiple update?
I make a table with a checkbox , and make a recordset and use the repeat selection so the table can show multi records.
before applying the repeat selection , I bind the CustomerID to the checkbox .
then I use the Multiple records update server behavior .
everything goes well , and then I do some test..
but it seems that *Every Rows* in the table update .
That's NOT what I want .
All I want is only records been*checked* will be updated.
(Something like multiple record insert " Skip if checkbox is not checked " or something like managing relationaltable which only insert the rows *been CHECKED* )
Any suggestion will be appreciated.
Thanks!
here is the code : (only WA DataAssist Multiple Updates)
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["Update_x"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_CustomerID");
$WA_connection = $connection;
$WA_table = "customer";
$WA_redirectURL = "customer_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "CustomerID";
$WA_fieldNamesStr = "Relationship|HomeNO";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connection;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("Relationship", $WA_multipleUpdateCounter) ."" . "|" . "".$row_SelectPrimaryContactor['HomeNO'] ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_where_fieldValuesStr = WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleUpdateCounter);
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$WA_multipleUpdateCounter++;
}
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "-1";
?>
And the table code in HTML :
<fieldset class="beautifyfieldset">
<legend class="legend">Select Families</legend>
<table>
<tr>
<td>Name</td>
<td>Identity</td>
<td>Birth</td>
<td>relationship</td>
<td>check</td>
</tr>
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_SelectFamily){
?>
<tr>
<td><?php echo $row_SelectFamily['NAME']; ?></td>
<td><?php echo $row_SelectFamily['Identity']; ?></td>
<td><?php echo $row_SelectFamily['Birth']; ?></td>
<td><label>
<select name="Relationship_<?php echo $RepeatSelectionCounter_1; ?>" id="Relationship_<?php echo $RepeatSelectionCounter_1; ?>">
<option>Relations</option>
<option value="1">father</option>
<option value="2">mother</option>
<option value="3">wife</option>
<option value="4">son</option>
<option value="5">daughter</option>
</select>
</label></td>
<td><label>
<input type="hidden" name="WADA_RepeatID_CustomerID_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_CustomerID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_SelectFamily["CustomerID"]; ?>" />
<input name="check_<?php echo $RepeatSelectionCounter_1; ?>" type="checkbox" id="check_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_SelectFamily['CustomerID']; ?>" />
</label></td>
</tr>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_SelectFamily && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_SelectFamily = mysql_fetch_assoc($SelectFamily);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</table>
</fieldset>