Drag & Drop Photos / Update MySQL

Đã hoàn thành Đã đăng vào Jun 4, 2008 Thanh toán khi bàn giao
Đã hoàn thành Thanh toán khi bàn giao

I am creating an interface for a client where they can drag and drop images to arrange the photo order. The new order must then update a MySQL database using PHP.

Database Fields: - Primary key is combination of photo_id and model_id

photo_id

model_id

photo_position

After the photos are reordered, it needs to update the photo_position field for the specified photo_id/model_id combination.

Here's the code I'm using... the drag and drop is working, but the database is not being updated. I'm told the javascript should refresh the page automatically and run the PHP script but I'm not very experienced with AJAX.

********************************************************************************************************************

MY CODE:

<?php

// (db connect & call recordset)

$model_id = $_GET['model_id'];

foreach(explode(",",$_GET['order']) as $key=>$value) {

mysql_query("UPDATE tbl_model_photo SET photo_position='" . $i . "' WHERE model_id = $model_id and photo_id = '" . $value . "'");

$i++;

}

?>

<html>

<body>

<div id="photo_arrange">

<?php do { ?>

<div id="photo_<?php echo $photo_id; ?>">

<img src="../images/models/photos/<?php echo $model_id; ?>/<?php echo $photo_id; ?>.jpg" />

</div>

<?php } while ($row_rs_photo = mysql_fetch_assoc($rs_photo)); ?>

</div>

<script type="text/javascript">

new Sortables($('photo_arrange'), {

onComplete: function() {

new Ajax("[url removed, login to view];?php echo $model_id; ?>&order="+[url removed, login to view](function(el) {

return [url removed, login to view]("photo_","");

})).request();

}

});

</script>

</body>

</html>

********************************************************************************************************************

JAVASCRIPT CODE:

Attached in file.

AJAX JavaScript PHP

ID dự án: #270293

Về dự án

3 đề xuất Dự án từ xa Jun 13, 2008 đang mở

Được trao cho:

devcenter

I can do it within hours. I've experienced this kind of task. Thanks.

$30 USD trong 0 ngày
(2 Đánh Giá)
1.6

3 freelancer chào giá trung bình$32 cho công việc này

samsolutions21

I am ready to start

$35 USD trong 0 ngày
(0 Nhận xét)
0.0