Jump to content

Recommended Posts

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>";
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/167372-help-command-queries-to-update-sql/
Share on other sites

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.

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.

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

`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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.