close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Update only saving last row with List/Menu

Thread begun 11/07/2009 4:40 pm by wendy.stevens392236 | Last modified 1/15/2010 1:04 pm by Eric Mittman | 4835 views | 19 replies |

wendy.stevens392236

Multiple Update only saving last row with List/Menu

I am trying to create a multiple row update page.... it works fine with text boxes, but I am now trying to add dynamic dropdown lists and on submit, only the last row actually saves.

<?php require_once('../../Connections/connSCHED.php'); ?>
<?php require_once("../../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_connSCHED, $connSCHED);
$query_rsBook = "SELECT * FROM book WHERE BOOK_ID > 1 AND BOOK_ID <30 AND TUNNEL = 1 ORDER BY LDATE ASC";
$rsBook = mysql_query($query_rsBook, $connSCHED) or die(mysql_error());
$row_rsBook = mysql_fetch_assoc($rsBook);
$totalRows_rsBook = mysql_num_rows($rsBook);

mysql_select_db($database_connSCHED, $connSCHED);
$query_rsCOACHES = "SELECT COACH_ID, NAME FROM coaches ORDER BY NAME ASC";
$rsCOACHES = mysql_query($query_rsCOACHES, $connSCHED) or die(mysql_error());
$row_rsCOACHES = mysql_fetch_assoc($rsCOACHES);
$totalRows_rsCOACHES = mysql_num_rows($rsCOACHES);?>
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["btnUPDATEALL"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_BOOK_ID");
$WA_connection = $connSCHED;
$WA_table = "book";
$WA_redirectURL = "../vbook_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "BOOK_ID";
$WA_fieldNamesStr = "LDATE|BDATE|WEEKDAY|BTIME|TUNNEL|COACH_ID|TEAM_ID|ATH_ID|BSTATUS|COMMENT|ACTIVE";
$WA_columnTypesStr = "',none,NULL|',none,NULL|',none,''|',none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|',none,''|',none,''|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connSCHED;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".$row_rsBook['LDATE'] ."" . "|" . "".$row_rsBook['BDATE'] ."" . "|" . "".$row_rsBook['WEEKDAY'] ."" . "|" . "".$row_rsBook['BTIME'] ."" . "|" . "".$row_rsBook['TUNNEL'] ."" . "|" . "".WA_AB_getLoopedFieldValue("dbCOACH_ID", $WA_multipleUpdateCounter) ."" . "|" . "".$row_rsBook['TEAM_ID'] ."" . "|" . "".$row_rsBook['ATH_ID'] ."" . "|" . "".$row_rsBook['BSTATUS'] ."" . "|" . "".$row_rsBook['COMMENT'] ."" . "|" . "".$row_rsBook['ACTIVE'] ."";
$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";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsBook){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rsBook['LDATE']; ?></td>
<td><?php echo $row_rsBook['TUNNEL']; ?></td>
<td><input type="hidden" name="WADA_RepeatID_BOOK_ID_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_BOOK_ID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rsBook["BOOK_ID"]; ?>" />
<select name="dbCOACH_ID_<?php echo $RepeatSelectionCounter_1; ?>" id="dbCOACH_ID_<?php echo $RepeatSelectionCounter_1; ?>">
<?php
do {
?>
<option value="<?php echo $row_rsCOACHES['COACH_ID']?>"<?php if (!(strcmp($row_rsCOACHES['COACH_ID'], $row_rsBook['COACH_ID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsCOACHES['NAME']?></option>
<?php
} while ($row_rsCOACHES = mysql_fetch_assoc($rsCOACHES));
$rows = mysql_num_rows($rsCOACHES);
if($rows > 0) {
mysql_data_seek($rsCOACHES, 0);
$row_rsCOACHES = mysql_fetch_assoc($rsCOACHES);
}
?>
</select></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php } while ($row_rsBook = mysql_fetch_assoc($rsBook)); ?>
</table>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td>No records match your request.</td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsBook && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsBook = mysql_fetch_assoc($rsBook);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
<P>
<input type="submit" name="btnUPDATEALL" id="btnUPDATEALL" value="Submit" />


</form>
</body>
</html>
<?php
mysql_free_result($rsBook);

mysql_free_result($rsCOACHES);
?>

Sign in to reply to this post

iain.sutherland290832

multiple record update

had the same issue last week after updating to dataassist 2.0.6 and tracked it down to the repeat counter line - yours currently reads:

$RepeatSelectionCounter_1_Iterations = "1";

I believe it should read:

$RepeatSelectionCounter_1_Iterations = "-1";

It was ultimately fixed by deleting the wincache file - (method at common_installation_issues.pdf ) and re-starting dw. It appears there was some legacy code in the wincache file.

I have advised WebAssist and they are looking at issuing a known issues doc

Sign in to reply to this post

wendy.stevens392236

Didn't work

I tried it and it still only updates the last records in the set. I think it has something do to with the dynamic list menu????

Sign in to reply to this post

Eric Mittman

Wendy, please explain a little about the steps you took to implement this on the page. I can review the info to determine if there is an issue with the steps you took. If not and you have tried the suggestions from the previous post let me know and I can open a ticket for you on this issue.

Sign in to reply to this post

wendy.stevens392236

Steps Taken

Hi - thanks for looking into this.

1. I tried the previous suggestions of deleting the file and changing the 1 to a -1 which did not work.

2. I followed the steps of the tutorial by:

a. creating form
b. creating record set for both the table to update (rsBOOK) and the dynamic menu/list (rsCOACHES)
c. created take to hold values - added text field for COACH_ID
d. created repeat region
e. in server behaviors, did the data assist multiple update records wizard.
THIS WORKED FINE (any changed row record updated perfectly)
f. then created new page and repeated above but....
g. instead of the text field, created a dynamic list menu from the rsCOACHES binding the COACH_ID to the rsBOOK COACH_ID field.
h. in testing page - the list menu is displaying correct "coach name" but on updating, only THE LAST ROW actually updates.

I am a newbie but can only assume it has something to do the the counter on the list menu not working? Any guidance would be great. Is there some "working code" with the use of a list menu that you could post that I could compare?

Sign in to reply to this post

Eric Mittman

Ok, thank you for the info, this is very helpful. So the page works ok with the input but fails when you have the select list on the page rite? If this is so I think I might understand why, it might be because you are using a single recordset for the select list and it is just pointing at the last record.

I will open a ticket for you on this so we can exchange some info. To update the ticket login to the site and visit your support history.

Sign in to reply to this post

kwsim

I'm having the same problem with version 2.0.6 on DW4. except I'm just using a single text field and it only updates the last record. I have a single recordset, which populates the default value of the text field and runs the DW repeat region. I apply the Update Multiple Records behavior wizard and test and I only get the last record updated. :mad:

Sign in to reply to this post

kwsim

I also had the $RepeatSelectionCounter_1_Iterations = "1"; and the change to -1 made no difference.

Sign in to reply to this post

Banksie

Having similar issues!

I'm having similar problems using DW8 and DA 2.0.6.!!!

Thought it was me so created a simple example of tables and pages and followed the video tutorial to the letter just to test the theory. My update page doesn't even update! Nor does it redirect - just refreshes the page with the original data still intact. I'm using a simple recordset and trying to update a single text field in each record.

Am still baffled as to why WA use the DW "Repeat Region" server behavior for some multiple operations (ie Insert multiple records) and the DA "Repeat Selection" for others (ie Delete & Update multiple records).

Over the past couple of weeks I've had a few problems with DA and, to be honest, I'm fast losing patience with it all!!!

Help! Advice please - or tranquilisers!!!

Sign in to reply to this post

Eric Mittman

To kwsim, what are the steps you are taking to get the multiple update in place? I'm looking into this issue but so far there is no problem with the multiple update that I have seen or can reproduce. Being able to reproduce the problem is key to getting it resolved. If you can please explain how you are implementing this and the exact result you are getting.

To gary, it seems that you may be experiencing a different problem since the others here are all getting updates to occur, just not getting the intended records to update. Please explain a little more about what you have tried and what the result is, if you are not getting redirected it would indicate that the update may not be getting triggered. I think it would be best for you to start a new thread for this and just reference your post on this thread so that we can help you more directly.

Sign in to reply to this post
loading

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...