Posting to database

I’ve found this drag and drop script and it’s brilliant but I can’t seem to get it to update the results in the database.

I’ve got this on the page:


<script language="Javascript">
	$(document).ready(function() {
			
			 // Initialise the table
			$('#images').tableDnD({
				onDragClass: "drag",
				onDrop: function(table, row) {	
				  alert($.tableDnD.serialize());	
					$.ajax({
					 type: "POST",
					 url: "http:/www.domain.com/new_site/admin/ajaxtest.php",
					 data: "" + $.tableDnD.serialize(),
					 success: function(html){
					 }
					});
				}
			});
	});

</script>

the alert box does give the correct values, but when I call the ajaxtest.php page nothing happens.
The ajaxtest.php page has this:


&lt;?php
include '../includes/db.php';
$images[] = $_POST['images'];
		$i = 0;
		if(!empty($images[0])){
			foreach($images as $value) {
				foreach($value as $row){
					$i++;
					if($row != 'tHeader'){
						$this-&gt;Image-&gt;set('id', $row);
						$this-&gt;Image-&gt;set('order', $i);
						$this-&gt;Image-&gt;save();
					}
				}
			}
		}
$con = mysql_connect($host,$username,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($database, $con);
$sql= sprintf("UPDATE `images` SET `order`='$i' WHERE `id`='$row'");
if (!mysql_query($sql,$con))
mysql_close($con)
?&gt;

I’m pretty sure the problem is with the $images[] = $_POST[‘images’]; but of code, but I’m not sure exactly where and would be extremely grateful for any help.

If you’re uploading any files to a database, they get sent by the $_FILES array. Be sure to sanitize them when uploading, eg is the file size within the range allowed, is the image size in the range allowed, etc

It’s not the actual files that are being uploaded just the order they’re displayed in. Each image as an order field and that’s all I’m trying to do is update that.