You are here: Re: Fix my AJAX Drag and Drop Code « PHP Programming Language « IT news, forums, messages
Re: Fix my AJAX Drag and Drop Code

Posted by ameshkin on 11/18/75 11:44

I don't understand whats wrong. I'm very new to PHP and this is
probably something very easy. This is the code.

<?php
$us = "ameshkin69";
mysql_connect('localhost', 'playlist', 'amir18');
mysql_select_db('playlist');
function parse_data($data)
{
$containers = explode(":", $data);
foreach($containers AS $container)
{
$container = str_replace(")", "", $container);
$i = 0;
$lastly = explode("(", $container);
$values = explode(",", $lastly[1]);
foreach($values AS $value)
{
if($value == '')
{
continue;
}
$final[$lastly[0]][] = $value;
$i ++;
}
}
return $final;
}

function update_db($data_array, $col_check)
{

foreach($data_array AS $us => $items)
{
$i = 0;
foreach($items AS $item)
{
$item = mysql_escape_string($item);
$us = mysql_escape_string($us);

mysql_query("UPDATE RecentUploads SET `order` = '$i' WHERE
`User` = '$us'");
$i ++;
}
}
}

// Lets setup Sajax
require_once('Sajax.php');
sajax_init();
// $sajax_debug_mode = 1;

function sajax_update($data)
{
$data = parse_data($data);
update_db($data, "AND (`User` = '$us')");
return 'y';
}

sajax_export("sajax_update");
sajax_handle_client_request();



echo $data;
?>

<style type="text/css">

#box {
width: 300px;
float: left;
margin-left: 5px;
}

body {
background: #FCFEF4 repeat-x;
margin: 10px 10px 10px 10px;
font-family: Arial, Verdana, Helvetica;
font-size: 76%;
color: #3F3F3F;
text-align: left;
}

h2 {
color: #7DA721;
font-weight: normal;
font-size: 14px;
margin: 20px 0 0 0;
}

br {
clear: left;
}
</style>

<link rel="stylesheet" href="lists.css" type="text/css">
<script language="JavaScript" type="text/javascript"
src="coordinates.js"></script>
<script language="JavaScript" type="text/javascript"
src="drag.js"></script>
<script language="JavaScript" type="text/javascript"
src="dragdrop.js"></script>
<script language="JavaScript" type="text/javascript"><!--
<?php
sajax_show_javascript();
?>
function confirm(z)
{
window.status = 'Playlist Updated';
}

function onDrop() {
var data = DragDrop.serData('g2');
x_sajax_update(data, confirm);
}

window.onload = function() {

list = document.getElementById("box");
DragDrop.makeListContainer( list, 'g2' );
list.onDragOver = function() { this.style["background"]
= "#EEF"; };
list.onDragOut = function() {this.style["background"] =
"none"; };
list.onDragDrop = function() {onDrop(); };

};

function getSort()
{
order = document.getElementById("order");
order.value = DragDrop.serData('g1', null);
}

function showValue()
{
order = document.getElementById("order");
alert(order.value);
}
//-->
</script></head>

<body>

<br />



<ul id="box" class="sortable boxy">
<?php


$r = mysql_query("SELECT * FROM `RecentUploads` WHERE `User` = '$us'
ORDER BY `UploadDate` ASC");
while($rw = mysql_fetch_array($r))
{
echo '<li id="'.$rw['FileName'].'">'.$rw['FileName'].'</li>';
}
?>
</ul>



</body></html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация