Location: PHPKode > projects > Standardized Test Practice Engine > stpe/admin/deletereviewsubmit.php
<?php
/*
Copyright 2004 by Jonathan Bell and Daniel Perelman
This file is part of STPE - the Standardized Test Practice Engine.

    STPE is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    STPE is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
include_once("../globals.inc.php");
?>
<?php
$wantedtopic = (int) $_POST['top'];
$wantedsection = (int) $_POST['sub'];

require_once("../dbinit.inc.php");
if(isset($_POST['review']))
{
	$sql = "SELECT * FROM `users` WHERE topicnum=$wantedtopic && sectionnum=$wantedsection";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);

while ($row = mysql_fetch_array($total_result)) {
	$groupid=$row['group_id'];
}
	mysql_query("DELETE FROM `reviews` WHERE topic_id = $wantedtopic AND section_id = $wantedsection;") or die(mysql_error());
	mysql_query("DELETE FROM `questions` WHERE topic_id = $wantedtopic AND section_id = $wantedsection;") or die(mysql_error());
	mysql_query("DELETE FROM `links` WHERE topic_id = $wantedtopic AND section_id = $wantedsection;") or die(mysql_error());
	mysql_query("DELETE FROM `credits` WHERE `id` = $groupid") or die(mysql_error());
	mysql_query("UPDATE `users` SET `group_id`=0 WHERE topicnum = $wantedtopic AND sectionnum = $wantedsection;") or die(mysql_error());
}
else
{
	foreach($_POST as $key => $value)
	{
		if(substr($key, 0, 4) == "link")
		{
			$linkid = (int) substr($key, 4);
			mysql_query("DELETE FROM `links` WHERE id = $linkid;") or die(mysql_error());
		}
	}
}

header("Location: deletereview.php?top=$wantedtopic&sub=$wantedsection");
?>
Return current item: Standardized Test Practice Engine