Ask a Question related to Dreamweaver AppDev, Design and Development.
-
AWS web #1
Link to update page selects wrong record
I built search and results pages that work fine but when i try to link from the
results page record to an update page that i built using the Record Update Form
Wizard in DWMX2004 it results page returns the first record in the db, not the
one linked from. The URL in the Results page address lists the correct record
information. I've attached code from the results page (linked from) first and
the update page (linked to) second. any help is greatly appreciated.
RESULTS PAGE
<?php require_once('../Connections/facconn.php'); ?>
<?php
$maxRows_results = 10;
$pageNum_results = 0;
if (isset($_GET['pageNum_results'])) {
$pageNum_results = $_GET['pageNum_results'];
}
$startRow_results = $pageNum_results * $maxRows_results;
$colname_results = "1";
if (isset($_GET['lastname'])) {
$colname_results = (get_magic_quotes_gpc()) ? $_GET['lastname'] :
addslashes($_GET['lastname']);
}
mysql_select_db($database_facconn, $facconn);
$query_results = sprintf("SELECT facID, firstname, lastname FROM faculty WHERE
lastname = '%s'", $colname_results);
$query_limit_results = sprintf("%s LIMIT %d, %d", $query_results,
$startRow_results, $maxRows_results);
$results = mysql_query($query_limit_results, $facconn) or die(mysql_error());
$row_results = mysql_fetch_assoc($results);
if (isset($_GET['totalRows_results'])) {
$totalRows_results = $_GET['totalRows_results'];
} else {
$all_results = mysql_query($query_results);
$totalRows_results = mysql_num_rows($all_results);
}
$totalPages_results = ceil($totalRows_results/$maxRows_results)-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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p> </p>
<p> </p>
<table border="1" cellpadding="2" cellspacing="3">
<tr>
<td>facID</td>
<td>firstname</td>
<td>lastname</td>
</tr>
<?php do { ?>
<tr>
<td><a href="fac_search_update2.php?recordID=<?php echo
$row_results['facID']; ?>"><?php echo $row_results['facID']; ?></a></td>
<td><?php echo $row_results['firstname']; ?></td>
<td><?php echo $row_results['lastname']; ?></td>
</tr>
<?php } while ($row_results = mysql_fetch_assoc($results)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($results);
?>
UPDATE PAGE
<?php require_once('../Connections/facconn.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}
$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 faculty SET firstname=%s, lastname=%s,
degree=%s, degreeb=%s, degreec=%s, bio=%s, appointed=%s WHERE facID=%s",
GetSQLValueString($_POST['firstname'], "text"),
GetSQLValueString($_POST['lastname'], "text"),
GetSQLValueString($_POST['degree'], "text"),
GetSQLValueString($_POST['degreeb'], "text"),
GetSQLValueString($_POST['degreec'], "text"),
GetSQLValueString($_POST['bio'], "text"),
GetSQLValueString($_POST['appointed'], "date"),
GetSQLValueString($_POST['facID'], "int"));
mysql_select_db($database_facconn, $facconn);
$Result1 = mysql_query($updateSQL, $facconn) or die(mysql_error());
}
mysql_select_db($database_facconn, $facconn);
$query_update = "SELECT * FROM faculty";
$update = mysql_query($query_update, $facconn) or die(mysql_error());
$row_update = mysql_fetch_assoc($update);
$totalRows_update = mysql_num_rows($update);
?>
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="update"
id="update">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">FacID:</td>
<td><?php echo $row_update['facID']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Firstname:</td>
<td><input type="text" name="firstname" value="<?php echo
$row_update['firstname']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Lastname:</td>
<td><input type="text" name="lastname" value="<?php echo
$row_update['lastname']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Degree:</td>
<td><input type="text" name="degree" value="<?php echo
$row_update['degree']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Degreeb:</td>
<td><input type="text" name="degreeb" value="<?php echo
$row_update['degreeb']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Degreec:</td>
<td><input type="text" name="degreec" value="<?php echo
$row_update['degreec']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Bio:</td>
<td><input type="text" name="bio" value="<?php echo $row_update['bio'];
?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Appointed:</td>
<td><input type="text" name="appointed" value="<?php echo
$row_update['appointed']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="facID" value="<?php echo $row_update['facID'];
?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($update);
?>
AWS web Guest
-
Update multiple selects
I have a list box on a form that allows for multiple selections. The selections are dumps into multiple rows and are tied into another table thru a... -
Update Record On Page Load
Hi I was wondering if anyone knew how to Update Record On Page Load. I have one feild in my database that I want to subtract 1 from each time the... -
update record on page load?
Using: ASP VBScript / MS Access / MX Hi, I would like to build a page which updates a record without the need to click a submit button. It is for... -
drop-down menu in update record page
Hi, I have created an update record page using the standard tools provided by dreamweaver. The page updates a record in an access database. All the... -
How to count record selects?
Hello all & thanks for looking, I was wondering if there's any way (for Oracle 9i2) to count the number of times a record is selected from the...



Reply With Quote

