View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How to update the checked rows with multiple update?

Thread began 11/24/2009 12:24 am by kakadong | Last modified 11/24/2009 12:43 am by kakadong | 632 views | 1 replies

kakadong

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>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...