Jump to content

Archived

This topic is now archived and is closed to further replies.

Theora

Retrieving record: not picking up passed parameter?

Recommended Posts

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:

[code]<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>[/code]

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:
[code]
<?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);
?>
[/code]

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!

Share this post


Link to post
Share on other sites
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

[quote author=Theora link=topic=103745.msg413358#msg413358 date=1155231768]
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:

[code]<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>[/code]

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:
[code]
<?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);
?>
[/code]

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!
[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.