close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Have to submit page twice to update table

Thread began 12/06/2010 1:50 am by acaciasd344844 | Last modified 12/06/2010 8:09 am by Jason Byrnes | 1234 views | 3 replies |

acaciasd344844

Have to submit page twice to update table

I am not sure whats going on here as I have used this function many times. When I try to update multiple rows using dataassist(2.0.6) I have to use a submit button and click it twice before the table is populated. This appears to be the only way the function works. It uses the Post method, but if I set it to Default, I get the following error...

Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Server at localhost Port 80

In previous versions of data assist non of this occurred I really don't know what's happening.

Normally, I would be able to go to the page and have it update automatically or simply get the customer to click a continue button and this would update the database. I Have added the page code, so you can see what is going on...

<?php require_once('../Connections/midas0001.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_midas0001, $midas0001);
$query_Recordsetupdatemultiple = "SELECT distinct(customerid), IF(Count(payments.paymentid) >= '1' and payments.code='PP', Count(payments.code='PP'), '') as orgreminderno, IF(Count(payments.paymentid) = '1' and payments.code='PP','Send Invoice','') as invoice, IF( Count(payments.paymentid) >'1' and payments.code='PP', 'Pre-Payments Left','') as invoice2, customerid, paymentid, reminderno FROM payments WHERE payments.stampoperative>= Date(now()) and payments.code='PP' GROUP BY payments.customerid";
$Recordsetupdatemultiple = mysql_query($query_Recordsetupdatemultiple, $midas0001) or die(mysql_error());
$row_Recordsetupdatemultiple = mysql_fetch_assoc($Recordsetupdatemultiple);
$totalRows_Recordsetupdatemultiple = mysql_num_rows($Recordsetupdatemultiple);

mysql_select_db($database_midas0001, $midas0001);
$query_Recordsetupdatecustomers = "SELECT * FROM customers";
$Recordsetupdatecustomers = mysql_query($query_Recordsetupdatecustomers, $midas0001) or die(mysql_error());
$row_Recordsetupdatecustomers = mysql_fetch_assoc($Recordsetupdatecustomers);
$totalRows_Recordsetupdatecustomers = mysql_num_rows($Recordsetupdatecustomers);

mysql_select_db($database_midas0001, $midas0001);
$query_Recordset1 = "SELECT reminderno FROM customers";
$Recordset1 = mysql_query($query_Recordset1, $midas0001) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);?>
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["Update"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_customerid");
$WA_connection = $midas0001;
$WA_table = "payments";
$WA_redirectURL = "";
$WA_keepQueryString = true;
$WA_indexField = "customerid";
$WA_fieldNamesStr = "reminderno";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_midas0001;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("orgreminderno", $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>Untitled Document</title>
</head>

<body>
<form action="" name="form1" id="form1">
<p>
<label></label>
<label>
<input type="submit" name="Update" id="Update" value="Update" />
</label>
<a href="test2.php">next</a></p>
<table width="200" border="1">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_Recordsetupdatemultiple){
?>
<tr>
<td nowrap="nowrap"><label>
<input type="hidden" name="WADA_RepeatID_customerid_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_customerid_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_Recordsetupdatemultiple["customerid"]; ?>" />
<?php echo $RepeatSelectionCounter_1; ?>
<input name="customerid_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="customerid_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_Recordsetupdatemultiple['customerid']; ?>" />
</label></td>
<td><label>
<input name="orgreminderno_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="orgreminderno_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_Recordsetupdatemultiple['orgreminderno']; ?>" />
</label></td>
<td><label>
<input name="reminderno_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="reminderno_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_Recordsetupdatemultiple['reminderno']; ?>" />
</label></td>
<td><label></label></td>
<td><label></label></td>
<td>
<label>
<input name="paymentid_<?php echo $RepeatSelectionCounter_1; ?>" type="text" id="paymentid_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_Recordsetupdatemultiple['paymentid']; ?>" />
</label></td>
<td>&nbsp;</td>
</tr>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_Recordsetupdatemultiple && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_Recordsetupdatemultiple = mysql_fetch_assoc($Recordsetupdatemultiple);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>
<?php
mysql_free_result($Recordsetupdatemultiple);

mysql_free_result($Recordsetupdatecustomers);

mysql_free_result($Recordset1);
?>


I hope you can help?

Thanks

John

Sign in to reply to this post

Jason ByrnesWebAssist

the problem is code order.



the recordset is created before the update record code.


so when the update button is pressed, the record is created with the old data, then the data is updated, then the page displays.


reorder the code so that the recordset code is after the update record code, this way the record will be updated, then the recordset will be created.

Sign in to reply to this post

acaciasd344844

THanx

Cheers Jason,

I got it working

Thanks again

Sign in to reply to this post

Jason ByrnesWebAssist

glad to hear it is working.

Sign in to reply to this post

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