richrock Posted September 16, 2008 Share Posted September 16, 2008 Hi, using the excellent scriptalicious library, I've decided to use this to allow dynamic listing/saving of items prior to printing a catalogue. However, it's not saving the updated list. This is compounded by the fact that there are several catalogues in the table (referred by 'cat'). So I've add the cat row to the sql commands, but still no dice. What I would like to do is refresh the list with the new lot numbers : here is my main page: <?php if($_POST['LotSort']) { echo "Sort Lots"; ?> <?php $sql = "select * from jos_bid_auctions where cat=1002 order by 'lot_num'"; $result = mysql_query($sql)or die(mysql_error()); $number = mysql_num_rows($result); for($x=1;$x<=$number;$x++){ $row = mysql_fetch_array($result); $list.= " <li id=\"item_$row[lot_num]\">ID: $row[id], Lot No: $row[lot_num], <strong>$row[title]</strong>, £$row[est_low]-£$row[est_high]</li>\n"; } ?> <script type="text/javascript" src="prototype-1.6.0.2.js"></script> <script type="text/javascript" src="scriptaculous/src/scriptaculous.js"></script> <style type = "text/css"> ul#sortlist{list-style:none;padding:0px;margin:0px} ul#sortlist li{padding:5px;border:1px solid #666666;margin:1px;font:normal 10px verdana;width:500px;color:#666666;background-color:#f0f0f0;cursor:move} #output{font:bold 10px verdana} </style> <ul id = "sortlist"> <?php echo $list; ?> </ul> <script type="text/javascript"> Sortable.create('sortlist',{ onUpdate:function(){ new Ajax.Updater('output','sort.php',{onComplete:function(request){}, parameters:Sortable.serialize('sortlist'), evalScripts:true, asynchronous:true}) } }) </script> <?php // End of cataloguing } ?> and the sort.php : <?php $connection = mysql_connect ("localhost", "root", "root"); $db= mysql_select_db("bromp-admin",$connection); debugMe(); print_r($_POST[sortlist]); foreach ($_POST[sortlist] as $varname => $varvalue) { echo "VarName: ".$varname; echo " - "; echo "VarValue: ".$varvalue."<br />"; $sql = "UPDATE jos_bid_auctions SET id = ".mysql_real_escape_string($varname)." WHERE id = ".mysql_real_escape_string($varvalue)." AND cat = 1002"; $result = mysql_query($sql) or die(mysql_error()); } echo "You just updated it on ".date("Y-m-d H:i:s"); ?> I've looked and looked. I even get the last line "You just updated..." as correct, but reloading the page shows the original order. Sure I'm missing something, but Ajax is new to me. R Quote Link to comment Share on other sites More sharing options...
richrock Posted September 16, 2008 Author Share Posted September 16, 2008 UPDATE : Having looked around all day for answers, I've now tried to add a lot_order column, but it's still not working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.