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"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </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> </td>
<td> </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> </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> </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);
?>