Jump to content


Photo

Retrieving record: not picking up passed parameter?


  • Please log in to reply
1 reply to this topic

#1 Theora

Theora
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 10 August 2006 - 05:42 PM

I'm trying to set up something that should be relatively simple; one page where the user selects the item they would like to update which passes them on to a second page where the record they selected is available for editing. I attempted to follow the instructions at livedocs.macromedia.com, but the second page isn't bringing up the selected record. This is what I have:

Page 1:

<table width="300" border="0" align="center" cellpadding="5">
  <tr>
    <td>Which page would you like to edit? </td>
  </tr>
  <?php do { ?>
    <tr>
      <td><a href="edit.php?recordID=<?php echo $row_rsContent['pagename_con']; ?>"><?php echo $row_rsContent['pagename_con']; ?></a></td>
    </tr>
    <?php } while ($row_rsContent = mysql_fetch_assoc($rsContent)); ?>
</table>

This part seems to work fine. When the next page comes up the url ends with ?recordID=main (for example).

The code for the second page:
<?php require_once('Connections/content.php'); ?>
<?php
$colname_rsEdit = "-1";
if (isset($_GET['id'])) {
  $colname_rsEdit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_content, $content);
$query_rsEdit = sprintf("SELECT primary_con, pagename_con, pagecontent_con FROM content WHERE pagename_con = '%s'", $colname_rsEdit);
$rsEdit = mysql_query($query_rsEdit, $content) or die(mysql_error());
$row_rsEdit = mysql_fetch_assoc($rsEdit);
$totalRows_rsEdit = mysql_num_rows($rsEdit);
?>
<!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=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="updating" name="updating" method="post" action="">
  <table width="500" border="0" align="center" cellpadding="15" cellspacing="0">
    <tr>
      <td>Updating <?php echo ucfirst($row_rsEdit['pagename_con']); ?></td>
    </tr>
    <tr>
      <td><textarea name="textarea" cols="55" rows="20"><?php echo $row_rsEdit['pagecontent_con']; ?></textarea></td>
    </tr>
    <tr>
      <td><input name="Update" type="submit" id="Update" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
mysql_free_result($rsEdit);
?>

It appears (to my untrained eye) that there is a query to select three things where the page name equals the variable passed from the previous page. It also appears that the large text area is trying to call in the contents of "pagecontent." I've tried both the quick (using the wizard) and step-by-step methods given on the Macromedia site and get the same results. Can you see what I'm doing incorrectly here?

Thanks!

#2 carlostau

carlostau
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 August 2006 - 07:04 PM

I have noticed that you have like a duplicated echo row there (highlghted in bold now).
My row goes like:
<a href="updatelist.php?recordID=<?php echo $row_rs_home['id']; ?>"
without having anything else. It might be a Dreamweaver bug that left the line with two echoes.
I would keep just the first part like the one I show here

Then on the edit page all you need to do is make sure to create a Recordset that has the URL.Variable and that the name of that variable is 'recordID' and not 'pagename_con'

Hope it helps!

Demian

I'm trying to set up something that should be relatively simple; one page where the user selects the item they would like to update which passes them on to a second page where the record they selected is available for editing. I attempted to follow the instructions at livedocs.macromedia.com, but the second page isn't bringing up the selected record. This is what I have:

Page 1:

<table width="300" border="0" align="center" cellpadding="5">
  <tr>
    <td>Which page would you like to edit? </td>
  </tr>
  <?php do { ?>
    <tr>
      <[b]td><a href="edit.php?recordID=<?php echo $row_rsContent['pagename_con']; ?>"><?php echo $row_rsContent['pagename_con']; ?></a></td>
    </tr>[/b]
    <?php } while ($row_rsContent = mysql_fetch_assoc($rsContent)); ?>
</table>

This part seems to work fine. When the next page comes up the url ends with ?recordID=main (for example).

The code for the second page:
<?php require_once('Connections/content.php'); ?>
<?php
$colname_rsEdit = "-1";
if (isset($_GET['id'])) {
  $colname_rsEdit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_content, $content);
$query_rsEdit = sprintf("SELECT primary_con, pagename_con, pagecontent_con FROM content WHERE pagename_con = '%s'", $colname_rsEdit);
$rsEdit = mysql_query($query_rsEdit, $content) or die(mysql_error());
$row_rsEdit = mysql_fetch_assoc($rsEdit);
$totalRows_rsEdit = mysql_num_rows($rsEdit);
?>
<!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=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="updating" name="updating" method="post" action="">
  <table width="500" border="0" align="center" cellpadding="15" cellspacing="0">
    <tr>
      <td>Updating <?php echo ucfirst($row_rsEdit['pagename_con']); ?></td>
    </tr>
    <tr>
      <td><textarea name="textarea" cols="55" rows="20"><?php echo $row_rsEdit['pagecontent_con']; ?></textarea></td>
    </tr>
    <tr>
      <td><input name="Update" type="submit" id="Update" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
mysql_free_result($rsEdit);
?>

It appears (to my untrained eye) that there is a query to select three things where the page name equals the variable passed from the previous page. It also appears that the large text area is trying to call in the contents of "pagecontent." I've tried both the quick (using the wizard) and step-by-step methods given on the Macromedia site and get the same results. Can you see what I'm doing incorrectly here?

Thanks!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users