Hey guys this is a problem kind of specific to what i'm trying to do on my site and i cant find an answer so i just throught i'd make my own question
What i'm trying to do:
When i press a button on my site it executes a javascript function. Within this JS function i create an array. The order of this array is key to the functionality of the AJAX request because the whole point is to be able to reorder the array to your liking.
The contents of this array represent mySQL rows.
I would like to be able to execute a php function upon button press which will take this array, and set values to the "Order" column of my table. ie: 1st element of the array gets its "order" value set to one. Last element of the array gets its "order" value set to N(however many there are).
Here is my current javascript:
<script>
$(document).ready(function(){
$( "#sortable" ).sortable({axis:"y"});
$("button").click(function(){
var sortedIDs = $( "#sortable" ).sortable("toArray");
var num = sortedIDs[0];
alert(num);
$.post({
url:"ajax2.php",
});
});
});
</script>
Here is what my ajax2.php page looks like:
<?php
include 'connect.php';
$sql = "UPDATE categories
SET cat_order=1
WHERE cat_id=5;";
$result = mysql_query($sql);
?>
I just put in numbers to test the functionality. In the end i would like to be able to use the information set in the javascript array "sortedIDs".
To make it clearer what i want to do in general....I'm creating a web forum and i would like to change the order of my forum categories on the main page. I have created a "sortable" jquery ui interface in order to do this. When you press the button on this interface it executes the js function i posted. It knows the order of the list of categories. And it knows the order after you change it.