Page 1 of 1

[HELP] Command + Queries to update SQL

Posted: Sat Jul 25, 2009 2:22 am
by bigfatpig
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.

Code: Select all

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

Re: [HELP] Command + Queries to update SQL

Posted: Sat Jul 25, 2009 6:34 am
by jackpf
Well, you can make two links to a page with ?id=$row['ID'] in the query string. One should have &action=approve and the other should have &action=deny.

On the page, you should run a query either updating the record with the id of $_GET['id'] to have a status of 1 if $_GET['action'] == 'approve', or deleting it if $_GET['action'] == 'deny'.