View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

data assist multiple record update

Thread began 10/29/2009 4:02 pm by iain.sutherland290832 | Last modified 10/30/2009 7:23 pm by iain.sutherland290832 | 1354 views | 6 replies

iain.sutherland290832

data assist multiple record update

I have used the update multiple record server behaviour successfully in the past, but since upgrade to 2.0.6 seem to have created a new page which does not update the data. I have re-created it several times and get the same issue.

Therre are 2 recordsets on the page, both filtered to the same item ItemCatID.

Only one recordset is involved in the muiltiple update and one corresponding table (items).

Any help appreciated.

code on the page is:

<?php require_once('../Connections/mayther.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;
}
}

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;
}
}


$colname_rs_ItemOrder = "-1";
if (isset($_GET['ItemCatID'])) {
$colname_rs_ItemOrder = (get_magic_quotes_gpc()) ? $_GET['ItemCatID'] : addslashes($_GET['ItemCatID']);
}
mysql_select_db($database_mayther, $mayther);
$query_rs_ItemOrder = sprintf("SELECT ItemID, ItemCatID, ItemName, ItemOrder FROM items WHERE ItemCatID = %s AND items.ItemName !='' ORDER BY items.ItemOrder", GetSQLValueString($colname_rs_ItemOrder, "int"));
$rs_ItemOrder = mysql_query($query_rs_ItemOrder, $mayther) or die(mysql_error());
$row_rs_ItemOrder = mysql_fetch_assoc($rs_ItemOrder);
$totalRows_rs_ItemOrder = mysql_num_rows($rs_ItemOrder);

$colname_rs_ItemCats = "-1";
if (isset($_GET["ItemCatID"])) {
$colname_rs_ItemCats = (get_magic_quotes_gpc()) ? $_GET["ItemCatID"] : addslashes($_GET["ItemCatID"]);
}
mysql_select_db($database_mayther, $mayther);
$query_rs_ItemCats = sprintf("SELECT * FROM itemcategory WHERE itemcategory.ItemCatID = %s", GetSQLValueString($colname_rs_ItemCats, "int"));
$rs_ItemCats = mysql_query($query_rs_ItemCats, $mayther) or die(mysql_error());
$row_rs_ItemCats = mysql_fetch_assoc($rs_ItemCats);
$totalRows_rs_ItemCats = mysql_num_rows($rs_ItemCats);?>
<?php
// WA DataAssist Multiple Updates
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_ItemID");
$WA_connection = $mayther;
$WA_table = "items";
$WA_redirectURL = "admin-change-the-order.php";
$WA_keepQueryString = false;
$WA_indexField = "ItemID";
$WA_fieldNamesStr = "ItemOrder";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_mayther;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("ItemOrderChange", $WA_multipleUpdateCounter) ."";
$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>admin</title>
<link href="maytheradmin.css" rel="stylesheet" type="text/css" />

</head>

<body class="twoColFixLtHdr">
<div id="container">
<div id="header">
<h1>Mayther Admin</h1>
<!-- end #header -->
</div>
<div id="mainContent">
<h3>Change the order <span class="tabletext">- Category: </span><?php echo $row_rs_ItemCats['ItemCatName']; ?></h3>

<form method="post" name="form1" id="form1">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rs_ItemOrder){
?>
<table width="100%" border="0" cellpadding="1">
<tr>
<th scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rs_ItemOrder['ItemID']; ?></td>
<td><?php echo $row_rs_ItemOrder['ItemCatID']; ?></td>
<td><?php echo $row_rs_ItemOrder['ItemName']; ?></td>
<td><input type="hidden" name="WADA_RepeatID_ItemID_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_ItemID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rs_ItemOrder["ItemID"]; ?>" />
<input name="ItemOrderChange_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="ItemOrderChange_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rs_ItemOrder['ItemOrder']; ?>" size="5" /></td>
</tr>
<?php } while ($row_rs_ItemOrder = mysql_fetch_assoc($rs_ItemOrder)); ?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="2"><label>
<input type="submit" name="update_<?php echo $RepeatSelectionCounter_1; ?>" id="update_<?php echo $RepeatSelectionCounter_1; ?>" value="Submit" />
</label></td>
</tr>
</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_rs_ItemOrder && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rs_ItemOrder = mysql_fetch_assoc($rs_ItemOrder);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</form>

<p>&nbsp;</p>
<p><a href="admin-change-the-order.php" class="greenlink">select a different category</a></p>
<p><a href="adminmenu.php" class="greenlink">back to admin menu</a></p>
<p>&nbsp;</p>

</div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />
<div id="footer">
<p>mayther 2009</p>

</div>

</div>
</body>
</html>
<?php
mysql_free_result($rs_ItemOrder);
mysql_free_result($rs_ItemCats);
?>

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