Help - Search - Members - Calendar
Full Version: Comments Help
Codegrrl.com Forums > Script Help > Tutorial Help
Phenix
I having a little issue with the comments, and I was wondering if anyone could help me. I wanted to configure my comments to sort of resemble this
// http://aethereality.net/index.php?subactio...&ucat=& but I'm not exactly sure how to do it.

Also, I was wondering if there was a way that I could have a link to my comments that opens up when I click it, sort of like this // http://aethereality.net/

Anyhelp would be appreciated. Please and Thanks. =]]
Amanda
First of all, I'd suggest you make a HTML template to resemble what you want your comments to look like. This coding is part of the individual entry page.

So, if you know you want the comments separated by a table (instead of by horizontal lines like in the tutorial), with the name linked next to the date, then the comment below it, you'd do something like this.
CODE
<table><tr><td><a href=$url>$name</a></td><td>$date</td></tr><tr><td colspan=2>$comment</td></tr></table>


It's all customizable with HTML...

And as far as clicking a link and having your comments show up, it should have been covered in the tutorial. Yeah, in part 7 where it says "Update: Let's add a snippet to the main page that both links the individual entry and gives a comment count..." gives you instructions on how to do that.

>>> If you've tried to make your comments look "prettier" and doesn't work out, post the code you have and we'll try to help you in the right direction smile.gif
Phenix
I'm not sure exactly where to add it now because when I did try to add it, it didn't work. sad.gif Heres the code I have so if someone could tell me what I need to do or what I'm doing wrong it would be greatly appreciated. Please and Thank You.

CODE

<?php include("header.inc");
mysql_connect ('***', '***', '***');
mysql_select_db ('***');

$sql = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 5";

$result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error());

while($row = mysql_fetch_array($result)) {


    $date = date("l F d Y  @ g:i A", $row['timestamp']);
    $title = stripslashes($row['title']);
    $entry = stripslashes($row['entry']);

    ?>
<div class="div" id="content">
    <p class="h1"><?php echo $title; ?></p>
    <p class="h2"><?php echo $date; ?></p><br />
    <p class="content"><?php echo $entry; ?>
    <hr /></p>

       <?php
    }

$commenttimestamp = strtotime("now");

$sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
    $timestamp = date("l F d Y", $row['timestamp']);
    printf("<hr />");
    print("<p>" . stripslashes($row['comment']) . "</p>");
    printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
    printf("<hr />");
}
?>


<form method="post" action="process.php">

<p class="content"><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" />
<input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>">

<table width="365" border="0" cellpadding="2" cellspacing="0" align="center">
  <tr class="commentsformtop">
    <td colspan="2"><div align="center">
      <label for="name"><strong>Post Comment</strong> </label>
    </div></td>
  </tr>
  <tr class="commentslook">
    <td width="83"><label for="email">Name:</label></td>
    <td width="299"><input type="text" name="name" id="name2" size="30" /></td>
  </tr>
  <tr class="commentslook">
    <td><label for="url">E-mail:</label></td>
    <td><input type="text" name="email" id="email2" size="30" /></td>
  </tr>
  <tr class="commentslook">
    <td valign="top"><label for="comment">URL:</label></td>
    <td><input type="text" name="url" id="url2" size="30" value="http://" /></td>
  </tr>
  <tr class="commentslook">
    <td valign="top">Comment:</td>
    <td><textarea cols="30" rows="5" name="comment" id="comment"></textarea></td>
  </tr>
  <tr class="commentslook">
    <td colspan="2" valign="top"><div align="center">
      <input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" />
    </div></td>
  <tr class="commentsformtop">
    <td colspan="2" valign="top">&nbsp;</td>
  </tr>
</table>

</form>
</div>
Phenix
I just realized that I left my info in there by mistake but I cant edit my page anymore, could some remove it for me, it really wasn't smart for me to leave it there blush.gif
Amelie
^ Done smile.gif
Phenix
Thanks SO Much biggrin.gif
Amanda
The information you'll need to edit is this:
CODE
printf("<hr />");
    print("<p>" . stripslashes($row['comment']) . "</p>");
    printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
    printf("<hr />");
Phenix
But when I try to change it, it doesn't work. sad.gif
Amanda
What code do you use when you try to change it?
Phenix
First I Tried something like this

CODE
<table width="390" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td width="100"><img src="file:///C|/Documents%20and%20Settings/****/My%20Documents/ViNTAGE%20HEART/images/avatar.gif" width="100" height="100"></td>
    <td width="282" rowspan="4">print("<p>" . stripslashes($row['comment']) . "</p>");</td>
  </tr>
  <tr>
    <td> printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>" </td>
  </tr>
  <tr>
    <td> stripslashes($row['url']) </td>
  </tr>
  <tr>
    <td>stripslashes($row['name']);</td>
  </tr>
</table>


And That Didn't Work. Then I tried something like this:

CODE
<table width="390" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td width="100"><img src="file:///C|/Documents%20and%20Settings/****/My%20Documents/ViNTAGE%20HEART/images/avatar.gif" width="100" height="100"></td>
    <td width="282">$commenttimestamp = strtotime("now");

$sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
    $timestamp = date("l F d Y", $row['timestamp']);
  
    print("<p>" . stripslashes($row['comment']) . "</p>");
    printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
  
}</td>
  </tr>
</table>


And that didn't work either. I know it user error, I'm just not sure where exactly I'm making the error. Any help would be greatly appreciated biggrin.gif
Phenix
Any Help?
Amelie
Please be patient when awaiting a reply - remember that everyone here gives their time voluntarily and the reason you might not have had a reply to your thread is because those that have seen it don't know how to help you, and those that can help you may not have logged in since your last reply.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.