Appending Comment Number Anchors to Comments
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-05-25T07:33:33Z
Indexed on
2010/05/25
7:41 UTC
Read the original article
Hit count: 240
Hello,
I am using a PHP file called comments.php that has a query that enters values into a mySQL table called "comment." As the query does this, it auto-generates a field called "commentid", which is set to auto_increment in MySQL. The file also contains a loop what echoes out all comments for a given submission.
It all works fine and dandy, but I want to simultaneously pull this "commentid" and turn it into a hashtag / anchor that when appended to the end of the URL makes that comment at the top of the user's browser.
Someone said on another question that in order to do this one thing I should do is create an anchor on the row where the comment is being printed out. How can I do this?
Thanks in advance,
John
The query that inserts comments into the MySQL table "comment":
$query = sprintf("INSERT INTO comment VALUES (NULL, %d, %d, '%s', NULL)", $uid, $subid, $comment);
mysql_query($query) or die(mysql_error());
The fields in the table "comment":
commentid loginid submissionid comment datecommented
The row in a loop where the comments are echoed out:
echo '<td rowspan="3" class="commentname1">'.stripslashes($row["comment"]).'</td>';
© Stack Overflow or respective owner