close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Tutorial for AJAX Sortable Rows with Data Assist

Thread began 1/21/2010 3:46 am by anonymous | Last modified 5/29/2015 7:07 pm by anonymous | 27178 views | 82 replies

Base5 Designs

Thanks brian a really good well laid out article.

am sure i will be using it a lot. with any luck WA will incorporate it in a future update.

I had a problem recently where i needed to have an order applied records added with the manage relational table command.

In this particular instance it was for a site where multiple images could be assigned to a record. the records in question were pages for the site where i wanted to be able to assign multiple images to display a slide show on each page.

I have just finished coding it and will update this post with detailed instructions on how to implement it.

I found myself needing to write it because in order for your code to work there needs to be order values already existing for the ordering to work, for example if all of the records contained 1 as he order field the re-ordering does not work.

anyway heres the code if anyone wants it, i will as i said update this post with instructions in the next few days.

The code needs to be placed after the relational table code and the $WA_redirect needs to be set in his code and not in the MRT code:

Dizzy B High
// WA DataAssist extension set order for relational data
if (isset($_POST["Update_x"])) // Trigger
$WA_keepOrder = 1;
$WA_keepOrder = $_POST['keepOrder'];
$WA_redirectURL = "/admin/pages/?menuID=".$_GET['menuID']."&prevLevel=".$_GET['prevLevel']."";
$WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_primaryKey = "id_pim"; // the primary key of the relational table
$WA_masterKey = "idsec_pim"; // the masterkey of the relational table
$WA_masterKeyValue = "".$row_WADAsections_sec['id_sec'].""; // the value of the master key
$WA_orderField = "order_pim"; // the order field
$WA_currentOrder = "";
$WA_relationalTable = "pageimages_pim"; // the name of the relational table
//Get the starting order number
mysql_select_db($database_conn_falken, $conn_falken);
$query_sortvalue = ("SELECT (MAX(".$WA_orderField.")+1) AS ".$WA_orderField." FROM ".$WA_relationalTable." WHERE ".$WA_masterKey." = ".$WA_masterKeyValue."");
$sortvalue = mysql_query($query_sortvalue, $conn_falken) or die(mysql_error());
$row_sortvalue = mysql_fetch_assoc($sortvalue);
$totalRows_sortvalue = mysql_num_rows($sortvalue);
$WA_sortValue = $row_sortvalue[$WA_orderField];
//get the list of records to apply numbering to
mysql_select_db($database_conn_falken, $conn_falken);
$query_WAsortitemlist = ("SELECT * FROM ".$WA_relationalTable." WHERE ".$WA_masterKey." = ".$WA_masterKeyValue." ORDER BY ".$WA_orderField." ASC");
$WAsortitemlist = mysql_query($query_WAsortitemlist, $conn_falken) or die(mysql_error());
$row_WAsortitemlist = mysql_fetch_assoc($WAsortitemlist);
$totalRows_WAsortitemlist = mysql_num_rows($WAsortitemlist);
if($totalRows_WAsortitemlist != 0){
do {
$WA_currentID = $row_WAsortitemlist['id_pim'];
if($WA_keepOrder == 1){
$WA_currentOrder = $row_WAsortitemlist[$WA_orderField];
if($WA_currentOrder == 0){
$WA_currentOrder = $WA_sortValue;
$WA_currentOrder = $WA_sortValue;
echo("new sort value = ".$WA_currentOrder."<br>");
//update order
if($row_WAsortitemlist[$WA_orderField] != $WA_currentOrder){
$WA_orderUpdateQuery = ("UPDATE ".$WA_relationalTable." SET ".$WA_orderField." = ".$WA_currentOrder." WHERE ".$WA_primaryKey." = ".$WA_currentID."");
echo("order update query: ".$WA_orderUpdateQuery."<br><br>");
mysql_query($WA_orderUpdateQuery) or die(mysql_error());
} while ($row_WAsortitemlist = mysql_fetch_assoc($WAsortitemlist));
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
header("Location: ".$WA_redirectURL);

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...