Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2012, 22:20
vicluber
 
Fecha de Ingreso: agosto-2009
Mensajes: 51
Antigüedad: 14 años, 8 meses
Puntos: 1
Consulta mysql en evento jquery

Buenas gente!

Para el laburo me pidieron una que a la tabla que se imprime desde mysql tenga registros reordenables. Osea que pueda alterar las posiciones. Me gusta sorteable de jquery...
Tienen algun link que me ayude a hacerlo con sortable de jquery? Ademas de la api de jquery... porque estoy suponiendo que mis tropiesos son con el php

También intente con "tablednd" y tengo esto:

Este scrip se apĺica a la tabla.

<script>
$(document).ready(function() {
$('#table-1').tableDnD({
onDragClass: "dragrow",
onDrop: function(table, row) {
// get the serialized data for transport
serial = $.tableDnD.serialize();
// use jQuery ajax function to send information
$.ajax({
type: "POST",
url: "test.php",
data: serial
});
}
});
});
</script>

Y este es el php.

<?php

include("conexion.php");
$link=Conectarse();

$table_1[] = $_POST['table-1'];
$i = 0;
if(!empty($table_1[0])){
foreach($table_1 as $value) {
foreach($value as $row){
$i++;
mysql_query("UPDATE productos SET orden='.$i.' WHERE id_producto = '.$row.'",$link);
}
}
}
?>

Si hago un alert del metodo serialize me devuelve el array... table_1[]=&table_1[]=2&table_1[]=3 (algo asi)

Así que ya estoy suponiendo que es un problema con el php, pero como no estoy seguro posteo acá, por favor si el post queda mejor en php moverlo please.

POR FAVORSITO!

Gracias