Bopo Posted April 13, 2009 Share Posted April 13, 2009 Hi Well this more of an advice question really, basically I have build a simple CMS, users can comment on articles, and obviously I have an admin section which allows the administrator to view all comments, which are output into a table. Naturally I want to allow the administrator to remove comments, however from a technical view the only method I could actually think of & implement right now would be to have a textbox, the admin types the comment id into it and clicks a button which deletes the comments, I know this solution has many flaws but I'm looking for a better method, I can think of dozens however I don't know how to implement them from a coding point of view. Here is the code I'm currently using <?php include("blogconnect.php"); $sql = "SELECT * FROM comments ORDER BY id DESC LIMIT 0, 10"; echo '<table width="250" border="1">'; echo '<tr> <td class="bh">ID</td> <td class="bh">Name</td> <td class="bh">Comment</td> <td class="bh">Date</td> </tr>'; $query = mysql_query($sql, $connect) or die (mysql_error()); while ($row = mysql_fetch_assoc($query)) { //this is where the error is highlighted echo '<tr>'; echo '<td>' . $row['id'] . '</td>'; echo '<td>' . $row['author'] . '</td>'; echo '<td>' . $row['comments']. '</td>'; echo '<td>' . $row['date']. '</td>'; echo '</tr>'; } echo '</table>'; ?> Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 13, 2009 Share Posted April 13, 2009 You could always just make a certain page in the admin panel that lists all comments in an array from the database. Then have another page that has a form on it with blank text fields. Whatever comment name link they click on would take the admin to this new page based on the name and id of the comment, where the text fields could be populated with the info for that certain topic with a delete button at the bottom. When the delete button is clicked, remove all instances of that comment from the database. Quote Link to comment Share on other sites More sharing options...
Bopo Posted April 13, 2009 Author Share Posted April 13, 2009 Awesome idea, that's something I definitely implement without much problem, also allowing the admin to modify the comment and save the changes wouldn't be too much trouble either . Thanks. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 13, 2009 Share Posted April 13, 2009 Yes, the exact same method could be used, have an update and delete button. Off course separate process for each. If you have any troubles just come back Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.