Location: PHPKode > projects > Standardized Test Practice Engine > stpe/admin/editimgwhich.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
include("login.inc.php");

include_once("../dbinit.inc.php");

if($_POST['action'] == "update"){
	for($x=$_POST['count'];$x>=1;$x--){
		$thistopicnum=$_POST["topicnumnew$x"];
		$thistopicdesc=$_POST["topicdescnew$x"];
		$thissectionnum=$_POST["sectionnumnew$x"];
		$thissectiondesc=$_POST["sectiondescnew$x"];
		$thisnames=$_POST["namesnew$x"];
		$thisteacher=$_POST["teachernamenew$x"];
		$newcode = substr(md5($thistopicnum.$thissectionnum."23".$thisnames),0,12);
		$sql = "UPDATE users SET topicnum='$thistopicnum', topicdesc='$thistopicdesc', sectionnum='$thissectionnum', sectiondesc='$thissectiondesc', names='$thisnames', code='$newcode', teachername='$thisteacher' WHERE id='$x'";
		$result = mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
			$thispage = $_SERVER['request_uri'];
header("Location: $thispage");
exit;
	}


}

$sql = "SELECT * FROM `users` order by id";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);

$x = 0;
while ($row = mysql_fetch_array($total_result)) {
	$id[$x]=$row['id'];
    $topicnum[$x]=$row['topicnum'];
    $topicdesc[$x]=$row['topicdesc'];
    $sectionnum[$x]=$row['sectionnum'];
    $sectiondesc[$x]=$row['sectiondesc'];
    $names[$x]=$row['names'];
    $code[$x]=$row['code'];
    $teachername[$x]=$row['teachername'];
	$x++;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><?php echo $site_name; ?> Admin</title>

<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<?php include("../header.inc.php"); ?>
	<table>
		<tr valign="top">
			<?php include("../nav.inc.php"); ?>
			<td class="maincontent">
			<h2>Select topic to edit or delete images for:</h2>
	<?php
	foreach($id as $key => $thisid){
		echo("<a href = \"editimg.php?top=$topicnum[$key]&#38;sub=$sectionnum[$key]\">$topicdesc[$key]: $sectiondesc[$key]</a><br />");
	}
	?>
<?php include("../footer.inc.php"); ?>
</td>
</tr>
</table>
</body>
</html>
Return current item: Standardized Test Practice Engine