Forum Moderators: coopster

Message Too Old, No Replies

Dreamweaver Recordset Update problem - HELP Please!

         

datagram1

12:59 am on Sep 9, 2010 (gmt 0)

10+ Year Member



I added a simple Recordset from my MySQL database, then added a repeating region, used the "update record" wizard, and put in a paging toolbar to show "Next", "Previous". The records are leads that the people in the company have to call. Once the lead is called, the "called" field now turns to a 'Y', and it will go into a separate webpage. My problem is....If you press next to get to the last record, then update it which sets the "called" field to 'Y' (Database only pulls called = 'N'), the form now still see's that all the records are there, but there is a row missing, it shows all blank fields now in my form....it doesnt update the new rows from the database for some reason? Ive been 3 days now working on this, cannot find a way to fix this, any suggestions?



<?
session_start();
if(!session_is_registered(un)){
header("Location: index.php");
}
?>

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

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE master SET companyname=%s, phone=%s, address=%s, city=%s, contactname=%s, callback=%s, callbacktime=%s, dts=CURDATE(), wn=%s, ni=%s, comments=%s, called=%s, dropoffsample=%s, timedropoffsample=%s WHERE cnt=%s",
GetSQLValueString($_POST['companyname'], "text"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['contactname'], "text"),
GetSQLValueString($_POST['callback'], "text"),
GetSQLValueString($_POST['callbacktime'], "text"),
GetSQLValueString($_POST['wn'], "text"),
GetSQLValueString($_POST['ni'], "text"),
GetSQLValueString($_POST['comments'], "text"),
GetSQLValueString($_POST['called'], "text"),
GetSQLValueString($_POST['dropoffsample'], "text"),
GetSQLValueString($_POST['timedropoffsample'], "text"),
GetSQLValueString($_POST['cnt'], "int"));

mysql_select_db($database_me, $me);
$Result1 = mysql_query($updateSQL, $me) or die(mysql_error());

$updateGoTo = "nl.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];

}
header(sprintf("Location: %s", $updateGoTo));
}

$maxRows_Recordset1 = 1;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;




mysql_select_db($database_me, $me);
$query_Recordset1 = "SELECT * FROM master WHERE called = 'N' ORDER BY city ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $me) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>


<!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>New Leads</title>
</head>

<body>
<div align="center">


<table width="100%" border="1" align="center" cellpadding="1" cellspacing="0">
<tr>
<td width="15%"><div align="center"><strong><img src="new.gif" border="0" align="middle" /> &nbsp;<font color="#FF0000">New Leads</font></strong></div></td>
<td width="16%"><div align="center"><strong><img src="call.gif" border="0" align="middle" /> &nbsp;<a href="ctb.php">Call Them Back</a></strong></div></td>
<td width="20%"><div align="center"><strong><img src="go.gif" border="0" align="middle" /> &nbsp;<a href="stdo.php">Samples To Drop Off</a></strong></div></td>
<td width="18%"><div align="center"><strong><img src="samplefollow.jpg" border="0" align="middle" /> &nbsp;<a href="sfu.php">Sample Follow Up</a></strong></div></td>
<td width="14%"><div align="center"><strong><img src="client.jpg" border="0" align="middle" /> &nbsp;<a href="c.php">Clients</a></strong></div></td>
<td width="17%"><div align="center"><strong><img src="clientfollow.gif" border="0" align="middle" /> &nbsp;<a href="Orders.php">Orders</a></strong></div></td>
</tr>
</table>
<div align="right">
<A href="success.php">Back</A> &nbsp;&nbsp; <A href="lo.php">LogOut</A>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75%" align="center">
<b>New Leads</b>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<?php do { ?>
<table border="1" align="center" bgcolor="#FFFF99">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Company Name:</td>
<td><input type="text" name="companyname" value="<?php echo htmlentities($row_Recordset1['companyname'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Phone:</td>
<td><input type="text" name="phone" value="<?php echo htmlentities($row_Recordset1['phone'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Address:</td>
<td><input type="text" name="address" value="<?php echo htmlentities($row_Recordset1['address'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">City:</td>
<td><input type="text" name="city" value="<?php echo htmlentities($row_Recordset1['city'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Called?</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="called" value="Y" <?php if (!(strcmp(htmlentities($row_Recordset1['called'], ENT_COMPAT, 'utf-8'),"Y"))) {echo "checked=\"checked\"";} ?> />
Yes</td>
</tr>
<tr>
<td><input type="radio" name="called" value="N" <?php if (!(strcmp(htmlentities($row_Recordset1['called'], ENT_COMPAT, 'utf-8'),"N"))) {echo "checked=\"checked\"";} ?> />
No</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Wrong Number?</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="wn" value="Y" <?php if (!(strcmp(htmlentities($row_Recordset1['wn'], ENT_COMPAT, 'utf-8'),"Y"))) {echo "checked=\"checked\"";} ?> />
Yes</td>
</tr>
<tr>
<td><input type="radio" name="wn" value="N" <?php if (!(strcmp(htmlentities($row_Recordset1['wn'], ENT_COMPAT, 'utf-8'),"N"))) {echo "checked=\"checked\"";} ?> />
No</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Time To Drop Off Sample:</td>
<td><input type="text" name="timedropoffsample" value="<?php echo htmlentities($row_Recordset1['timedropoffsample'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="middle">
<td nowrap="nowrap" align="right" valign="middle">Comments:</td>
<td><textarea name="comments" cols="50" rows="5"><?php echo htmlentities($row_Recordset1['comments'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><center>

<input type="submit" value="Update record" <?php $pageNum_Recordset1 - 1 ?>/></center></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="cnt" value="<?php echo $row_Recordset1['cnt']; ?>" />
</form>
<table border="0">
<tr>
<td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a>
<?php } // Show if not last page ?></td>
<td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a>
<?php } // Show if not last page ?></td>
</tr>
</table>
Records: <?php echo $totalRows_Recordset1 ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</td>
<td width="25%"><center><strong><font size="+1">7 Flavors Available: </font></strong><BR />
Vanilla, Orange, Peppermint, Strawberry, Raspberry, Blueberry, Cinnamon<BR /><BR /><strong>Price:</strong><BR />$7 per Gram<BR /> Depends how much purchased
<br /><br /><br /><BR /><BR /><BR /><BR />
</center>
</td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

coopster

11:20 am on Sep 28, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, datagram1.

I'm guessing not a lot of responses here because that's a lot of code and typically members don't want to sift through so much (see the PHP Forum Charter [webmasterworld.com] for details). Can you trim down to the problem area?