Hi;
how can i show the delete and edit link to the user who has posted the comment just like in facebook only the person who has posted the comment is allowed to edit or delete the comment below is my code

    <?php
//including the database connection file
include_once("includes/settings.php");
connect();

//fetching data in descending order (lastest entry first)
$result=mysql_query("SELECT * FROM comments ORDER BY id DESC");

echo "<table width='80%' border=0>";

echo "<tr bgcolor='#CCCCCC'>";
echo "<td>Name</td>";
echo "<td>Comments</td>";;
echo "</tr>";

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

    echo "<tr>";
    echo "<td>".$res['Name']."</td>";
    echo "<td>".$res['Comments']."</td>"; 
    echo "<td><a href=\"edit_comment.php?id=$res[id]\">Edit</a> | <a href=\"includes/delete.php?id=$res[id]\">Delete</a></td>";

}
echo "</table>";
?>
Member Avatar for LastMitch

how can i show the delete and edit link to the user who has posted the comment just like in facebook only the person who has posted the comment is allowed to edit or delete the comment below is my code

You can do that for any CMS or framework not just Facebook. The code you provided is inconclusive. It involve more code than just a query. I think you didn't know or not sure but this is from the admin section another words that person has to be register member and can do that. This is a little more work than you expected.

If you want that featuere then used this:

http://developers.facebook.com/docs/reference/plugins/comments/

If that's not what you need or want then my suggestion find another alternative. Your option is very limited.

the user is registered and also using sessions

You could store the users email address along with the post. Then tjeck if logged in user has the same email address, as the author of the post which is currently being viewed - If so: echo edit/delete link..

Get the point?

EDIT: I understood your question as if you wanted similar functionality LIKE on Facebook, not that it was ON Facebook..

Anyways, hope it helps you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.