Location: PHPKode > projects > ZompLog > admin/reorder.php
<?php
ob_start();
include_once("functions.php");
include("config.php");
include("session.php");
include("header.php");

$user = loadUser($_SESSION['login'],$link,$table_users);
$entry = loadEntry($link,$table);

if(!$_SESSION["loggedIn"]){
?>

You are not allowed to view this page, please log in first.
<?php
}
else
{

if(isset($_POST['sortableListsSubmitted'])) {

	$orderArray = SLLists::getOrderArray($_POST['categoriesListOrder'],'categories');
	
	foreach($orderArray as $item) {

		$query = "UPDATE $table_files SET fileorder=".$item['order']." WHERE id=".$item['element'];
		$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	}
	
	$myreferer = $_POST['referer'];
	
	header("Location: editor.php?id=".$myreferer);
	ob_end_flush();
	 }

}

?>

<div id="submenu"><a href="editor.php?id=<?php echo $_GET['id']?>" class="sub">back to entry</a> </div>


<div id="side">
<div class="title">&nbsp;</div>
<div class="box"><?php
if(!empty($messages)){
	displayErrors($messages);
}

elseif($_GET[message] && empty($messages)){
displayMessage($_GET[message]);
  }

else{
echo "On this page you can reorder images and files.";
}  
  
?>
</div></div>


<div id="main">

<?php 

$query = "SELECT * FROM $table_files WHERE entry_id = '$_GET[id]' AND full_url != '1' ORDER by fileorder";
$result = mysql_query($query, $link);
$numrows = mysql_num_rows($result);
if($numrows){
?>


		  	     <fieldset id="titlediv">
      <legend>Reorder images and Files</legend>
	<ul id="categories" class="sortableList">
	
<?php

while($row = mysql_fetch_array($result)){
if($row[type] == 'image/jpeg' || $row[type] == 'image/gif'){
echo "<li id=\"item_$row[id]\"><img src='../upload/thumbnail.php?gd=2&src=$row[name]&maxw=100' border='0'></li>";
}
else
{
// fix to get the real name of the file
$name = substr($row[name],13);
$filename = urlencode($row[name]);
echo "<li id=\"item_$row[id]\"><a href='../upload/force_download.php?file=$filename&amp;type=$row[type]'>$name</a></li>";
}
}


?>
</ul>

<?php
}
$sortableLists->printForm($_SERVER['PHP_SELF'], 'POST', 'Reorder', 'button');
?>

		</fieldset>
	<?php 
$sortableLists->printBottomJS();


include ("footer.php");
?>
Return current item: ZompLog