bigfatpig Posted July 25, 2009 Share Posted July 25, 2009 Hi all, I need help regarding the following issue. Say for example I am creating a Adminpanel that allows an admin to monitor the site. I wish to have a function whereby admin can approve or delete reveiws submitted by users. I have a database table named reviews, and a field review_status = (default at 0) so when a user submits a review, the status is set at 0. What should I script in the PHP so that the admin can insert into review_status that an approved review would have 1 and if the review contains anything unwanted the admin can delete the review? Your help and suggestion is greatly appreciated. Please advice. <? echo "</head> <body onload=\"FullScreen_go();\"> <div>"; $header = "Pending Reviews"; include("header.html.php"); $query = "SELECT * FROM reviews where review_status = 0 ORDER BY id ASC"; $approve = ""; $delete = ""; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_row($result)) { echo "<div style='height:65px;'><tr>"; echo "<td><ul><font color=666666>Restaurant:</font>".$row[1]."<br>"; echo "<font color=666666>Title: </font>".$row[6]."<br>"; echo "<font color=666666>Review: </font>".$row[7]."<br>"; echo "<font color=666666>Written By: </font>".$row[8]."<br>"; echo "<font color=666666>Date Joined: </font>".$row[9]."<br>"; echo "<font color=666666>Review Status:</font><b> Approve | Delete </b><br>"; echo "</tr>"; echo "</table>"; echo "</div>"; } ?> Quote Link to comment Share on other sites More sharing options...
RussellReal Posted July 25, 2009 Share Posted July 25, 2009 UPDATE tableName SET review_status = '1' WHERE review_id = 'the_review_id' Quote Link to comment Share on other sites More sharing options...
bigfatpig Posted July 25, 2009 Author Share Posted July 25, 2009 Hi, thanks a lot for your help. But how do i fetch the_review_id? Quote Link to comment Share on other sites More sharing options...
cs.punk Posted July 25, 2009 Share Posted July 25, 2009 Hi, thanks a lot for your help. But how do i fetch the_review_id? Create a column in your database with a auto increment column. So each entry will have a ID to it... Quote Link to comment Share on other sites More sharing options...
bigfatpig Posted July 25, 2009 Author Share Posted July 25, 2009 CREATE TABLE IF NOT EXISTS `reviews` ( `id` int(11) NOT NULL auto_increment, `rname` varchar(45) NOT NULL, `food` int(2) NOT NULL, `ambience` int(2) NOT NULL, `value` int(2) NOT NULL, `service` int(2) NOT NULL, `title` varchar(50) NOT NULL, `comment` varchar(200) NOT NULL, `writtenby` varchar(50) NOT NULL, `date` datetime NOT NULL, `review_status` int(1) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; This is my table for the database. Quote Link to comment Share on other sites More sharing options...
ignace Posted July 25, 2009 Share Posted July 25, 2009 I would advice to work with certain states so a review may be PENDING (or NEW), HOLDING, APPROVED or ARCHIVED. A new review would have the state PENDING and could get the state HOLDING (multiple reviews may come in and you want to pick the better one) after PENDING or HOLDING a review can change state to APPROVED (published to the website) only APPROVED reviews will be archived after some time. You can automate the archiving process by adding a archive_date column to your table. When the date is hit, the review state is changed to ARCHIVED. Quote Link to comment Share on other sites More sharing options...
bigfatpig Posted July 25, 2009 Author Share Posted July 25, 2009 Currently not so advanced in coding hence I would just like to do a simple approve review and delete review from the table if it is found unappropriate. What do I have to include at the Approve / Delete codes so that the whole SQL command would work? Thanks for your help Quote Link to comment Share on other sites More sharing options...
cs.punk Posted July 27, 2009 Share Posted July 27, 2009 `id` int(11) NOT NULL auto_increment, `rname` varchar(45) NOT NULL, `food` int(2) NOT NULL, `ambience` int(2) NOT NULL, `value` int(2) NOT NULL, `service` int(2) NOT NULL, `title` varchar(50) NOT NULL, `comment` varchar(200) NOT NULL, `writtenby` varchar(50) NOT NULL, `date` datetime NOT NULL, `review_status` int(1) NOT NULL default '0', $sql_u_statues = "UPDATE review_status SET review_status = '1'"; Make a page that displays all of your '0' entries. Then make a form with each entry having a 'checkbox' (passing along the id of the entry). And once the form is set, use the above code to update it to 1. For the public view, let it show only entries with review_status on 1. 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.