Location: PHPKode > projects > Teacher Evaluation based on phpsurveyor > DONT USE/mod_evaluation/batchdeletesurveys.php
<?php
//batchdelete
require_once("header.php");
$_GET['ok']="ok";
set_time_limit(0);

{//get largest teacher sid
	$result=mysql_query("SELECT max(sid) as max FROM {$dbprefix}surveys");
	$maxline=mysql_fetch_assoc($result);
	$to=$maxline["max"];
}
{//get lowest teacher sid
	$sidquery = "SELECT sid FROM {$dbprefix}surveys ORDER BY sid ASC LIMIT 3";
	$sidres = mysql_query($sidquery);
	while ($srow = mysql_fetch_assoc($sidres)) {$thissid = $srow['sid'];}
	$from=$thissid;
}

//before deleting surveys the results should be saved.
if($from<=2){
	$from=3;
}
echo "<br>Delete from surveys $from to survey $to<br><hr>";

for($i=abs($from);$i<=$to;$i++){
	$_GET['sid']=$i;
	echo "deleting Survey  {$_GET['sid']} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	ob_start();
	require "../admin/deletesurvey.php";
	ob_end_clean();
}

mysql_query("TRUNCATE TABLE pretoken");
/**
echo "<hr>";
//clean up labels -- only for development RELEASE TODO
echo "<br>";

$return=mysql_query("delete from labels where lid>".SURVEY_TEMPLATE_SID);
	echo "deleted labels: " . mysql_affected_rows() . " return=$return<br>";
$return=mysql_query("Delete from labelsets where lid>".SURVEY_TEMPLATE_SID);
	echo "deleted labelsets:". mysql_affected_rows(). " return=$return<br>";
$return=mysql_query("alter Table surveys AUTO_INCREMENT=". SURVEY_TEMPLATE_SID ."+1");
	echo "auto_increment reset to: ".  SURVEY_TEMPLATE_SID+1 . "<br>";
//*/
echo "<p>Batch delete finshed</p>";
require("footer.php");
?>
Return current item: Teacher Evaluation based on phpsurveyor