Solved

problem with updating comments in a blog

Posted on 2006-10-23
9
156 Views
Last Modified: 2010-04-25
hi
i am folowing this tutorial, and i am stuck with updating the comments.
http://www.adobe.com/devnet/dreamweaver/articles/php_blog5_03.html

i do not use the extension.
so i have built 2 pages: list_comm.php and edit_com.php.
i created a list from a recordset and added an update button wich goes to the edit page with the URL parameter of the id_com.

then i built the update form, which can edit the text and say if the comment will be sown or not. therefore i used a checkbox.

well it works but only parcially. i select a comment and click the update button. and indeed the edit page loads with the selected comment. then i check or uncheck the valid checkbox, and click "update".

then the list of comments load and the change indeed is shown there.

but when i go to the article that this comment is attached to, it is not shown. there fore there has been an update but it is shows only in the admin area and not in the front-end blog.

what am i doing wrong?

best regards

ron
0
Comment
Question by:derrida
  • 5
  • 4
9 Comments
 
LVL 1

Author Comment

by:derrida
ID: 17787213
hi
i now see that i have 2 other problems that i hope you can help me with:
regarding this section of that tutorial: http://www.adobe.com/devnet/dreamweaver/articles/php_blog4_08.html

first problem: the date for the erticle itself is displaying fine, but when someone post a comment the date dose not show, even though the right dynamic element is in the form (rsComments.date_com). in the database both the article date and the comment date are set with the same parameters.

second problem: even though the tutorial say that a comment will be shown only after the manager validate it, when i insert a comment it appears immediatly.

i really appriciate any help.

ps. i hope jason will read it and continue with his great help.

ron
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17789919
Ron,

Since you are not using Interakt's extensions, it's easier for us if you post the PHP code from your pages (not the HTML, unless we ask for it later).
0
 
LVL 1

Author Comment

by:derrida
ID: 17790326
hi
thanks for answering:

this is the recordset for updating:
$colname_rsCommentUpdate = "-1";
if (isset($_GET['id_com'])) {
  $colname_rsCommentUpdate = (get_magic_quotes_gpc()) ? $_GET['id_com'] : addslashes($_GET['id_com']);
}
mysql_select_db($database_connBlog, $connBlog);
$query_rsCommentUpdate = sprintf("SELECT * FROM blg_comment_com WHERE id_com = %s", GetSQLValueString($colname_rsCommentUpdate, "int"));
$rsCommentUpdate = mysql_query($query_rsCommentUpdate, $connBlog) or die(mysql_error());
$row_rsCommentUpdate = mysql_fetch_assoc($rsCommentUpdate);
$totalRows_rsCommentUpdate = mysql_num_rows($rsCommentUpdate);



and this is the update form:


 <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
          <table align="center">
            <tr valign="baseline">
              <td nowrap align="right" valign="top">Comment:</td>
              <td><textarea name="text_com" cols="50" rows="5"><?php echo $row_rsCommentUpdate['text_com']; ?></textarea>
              </td>
            </tr>
            <tr valign="baseline">
              <td nowrap align="right">Valid:</td>
              <td><input type="checkbox" name="valid_com" value=""  <?php if (!(strcmp($row_rsCommentUpdate['valid_com'],0))) {echo "@@checked@@";} ?>></td>
            </tr>
            <tr valign="baseline">
              <td nowrap align="right">&nbsp;</td>
              <td><input type="submit" value="Update "></td>
            </tr>
          </table>
          <input type="hidden" name="MM_update" value="form1">
          <input type="hidden" name="id_com" value="<?php echo $row_rsCommentUpdate['id_com']; ?>">
        </form>


this is the recordset for the list page, that shows the list of comments:

mysql_select_db($database_connBlog, $connBlog);
$query_rsComments = "SELECT * FROM blg_comment_com ORDER BY date_com DESC";
$query_limit_rsComments = sprintf("%s LIMIT %d, %d", $query_rsComments, $startRow_rsComments, $maxRows_rsComments);
$rsComments = mysql_query($query_limit_rsComments, $connBlog) or die(mysql_error());
$row_rsComments = mysql_fetch_assoc($rsComments);

if (isset($_GET['totalRows_rsComments'])) {
  $totalRows_rsComments = $_GET['totalRows_rsComments'];
} else {
  $all_rsComments = mysql_query($query_rsComments);
  $totalRows_rsComments = mysql_num_rows($all_rsComments);
}
$totalPages_rsComments = ceil($totalRows_rsComments/$maxRows_rsComments)-1;

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

and this is the form for the list:

<?php echo ($startRow_rsComments + 1) ?> to <?php echo min($startRow_rsComments + $maxRows_rsComments, $totalRows_rsComments) ?> of <?php echo $totalRows_rsComments ?>      <br />
      <table cellpadding="3" cellspacing="0" class="topic">
          <tr class="nugheader">
            <td>Comment</td>
            <td>user number</td>
            <td>date</td>
            <td>valid</td>
            <td>&nbsp;</td>
          </tr>
          <?php do { ?>
            <tr>
              <td><?php echo $row_rsComments['text_com']; ?></td>
              <td><?php echo $row_rsComments['idusr_com']; ?></td>
              <td><?php echo $row_rsComments['date_com']; ?></td>
              <td><?php echo $row_rsComments['valid_com']; ?></td>
              <td><a href="edit_com.php?id_com=<?php echo $row_rsComments['id_com']; ?>"><img src="../images/update.gif" alt="update" width="23" height="23" border="0" /></a></td>
            </tr>
            <?php } while ($row_rsComments = mysql_fetch_assoc($rsComments)); ?>

sorry to post all that code.

i think that the problem is with the recordsets but i`m not sure what i am doing wrong there.
maybe its too simple and i need to use the advanced  recordset and to combine another table?

in any case i really appriciate your help.

ron
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17800455
Ron,

I have not forgotten you.  I've had some RL stuff to take care of.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 250 total points
ID: 17801109
Okay,

I see your recordset code, what I don't see is the code that updates the comment table after the form is submitted.  Where is the update behavior?

Also, a brief word about the Interakt stuff.  You don't need to have it installed to do most of the tutorial.  The Interakt extensions will automate form building and form validation, but if you know how to build forms, all you need to do is apply the DW Insert or Update Record behaviors to get the same functionality.  The Interakt stuff adds a lot of extra functionality and is quite advanced if you dig into it but the basic Insert and Update functions aren't a heck of lot different than DW.  If  the tutorial asks you to use Interakt's Update function, just make the same form and apply DW's update function.  Same effect, minus the form validation.
0
 
LVL 1

Author Comment

by:derrida
ID: 17802099
hi jason

thanks for the answer.
well now i am updating the comment table:) it works.

so now there is the older problem that even though i put the date dynamic element in the comment table in DW , and even though it has the same values as the date field in the database, the date appear for the article but not for the comment.

another issue comes in the next chapter of the blog tutorial.
concerning this section:http://www.adobe.com/devnet/dreamweaver/articles/php_blog5_05.html

i created a user list page and added an update button which take the id_usr.
a problem that arises is: when i click the update button i go to the edit_user page but it does not set the user i have chosen from the list. i thought that when i asked for the id_usr, the edit page will come up with this user info.

then i created a form like the tutorial make (nextensio form, but i`m doing it without the extension).
there are 4 buttons there. icreated each one but have no idea how to make them function correctly.

again, i am very thankfull for your great help.

ron

0
 
LVL 1

Author Comment

by:derrida
ID: 17802471
hi
i hope i can ask another question which shows hoe much a begginer i am:)

in myadmin when i build a table i have some choises but in most cods i see they have it either as MyISAM or InnoDB.
how do i know what to chose and what is the difference between them?

best regards

ron
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17804534
Ron,

We should keep the question to one per thread.  If the comment table is updating, let's close this and repost the next two questions so that other experts have a shot at helping you.
0
 
LVL 1

Author Comment

by:derrida
ID: 17804840
ho ok:)
sorry
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now