1

Code:

<div class="menu" id="menu-pages">  

<?php
$query = mysql_query("SELECT * FROM {$statement}");
while ($row = mysql_fetch_assoc($query)) { printf('

<div id="dataContent">
<a name="'.$row['posicao'].'"><li style="list-style-type: none;" class="clients" id="page_%s">

<form method="post" action="actions/dados_update.php?id='.$row['id'].'">
<div class="wid5"><input type="text" name="posicao" value="'.$row['posicao'].'" /></div>
<div class="wid5" style="background:url(images/artigos/'.$row['imagem'].') center no-repeat;background-size:contain;"><input type="file" value="" class="file'.$row['id'].'" /></div>
<div class="wid5"><input type="text" readonly name="imagem" value="'.$row['imagem'].'" class="filename'.$row['id'].'" /></div>
<div class="wid20"><textarea name="titulo">'.$row['titulo'].'</textarea></div>
<div class="wid25"><textarea name="desc" id="field">'.$row['desc'].'</textarea></div>
<div class="wid10"><input type="text" name="quantidade" value="'.$row['quantidade'].'" /></div>
<div class="wid10"><input type="text" name="unitario" value="'.$row['unitario'].'" /></div>
<div class="wid10"><input type="text" readonly name="iliquido" placeholder="'.number_format($row['unitario']*$row['quantidade'],2).'€" /></div>
<div class="wid5"><input type="submit" value="Editar" /></div>
<div class="wid5"><input type="button" value="Arrastar" /></div>
</form>

</li></a></div>', $row['id'], $row['id']); ?>

<?php    
}
?>

</div>

Script:

<script language="javascript">
$(document).ready(function(){
$("#menu-pages").sortable({
update: function(event, ui) {
$.post("ajax.php", { type: "orderPages", pages: $('#menu-pages').sortable('serialize') } );
}
});
});
</script>

Ajax.php

<?php
mysql_connect('localhost','root','');
mysql_select_db('valsil') or die( "Unable to select database");

parse_str($_POST['pages'], $pageOrder);
foreach ($pageOrder['page'] as $key => $value) {
mysql_query("UPDATE dados SET `posicao` = '$key' + 1 WHERE `id` = '$value'") or die(mysql_error());
}
?>

So the main goal is making a sortable data from database and when organized the position changes itself and updates it to the database automatically.

I did this in a previous work and it worked fine but im trying again and its not working.

I rechecked the code but still couldnt find the problem.

Any help would be usefull. Cumps.

Bruno
  • 99
  • 1
  • 10

1 Answers1

0

Since you state that its the same code as your previous work and its worked fine why not check your PHP versions you use before and now? Check this http://php.net/manual/en/migration55.deprecated.php also this Deprecated: mysql_connect()

Community
  • 1
  • 1