re-ordering items in a results page
Hi Jason
In the backend of a site I have created a results page which allows the user to re-order items in the list. I have used this loads of times succcessfully, but for some reason, and I cannot see why or what I have done wrong on this occasion, but when I click on 'update order' I get the following:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order = 1 WHERE OffersID = 3' at line 1
My table is named special_offers and the columns in it are OffersID, Date, OfferTitle, OfferContent, MetaTitle, MetaDescription, Live, Order
Here from the the code that I have been using, and the other code snippet is what I am using in the table within the form itself.
<?php
function cmp($a, $b) {
return ($a[2] < $b[2] || ($a[2] == $b[2] && $b[2] == $b[1]))? -1: 1;
}
if (isset($_POST["UpdateOrder"])) {
$OrderArray = array();
$start = 1;
while (isset($_POST["OffersID_".$start])) {
$OrderArray["SpecialOffers_". $_POST["OffersID_".$start]] = array($_POST["OffersID_".$start],$start,$_POST["Order_".$start]);
$start ++;
}
$start = 1;
uasort($OrderArray, "cmp");
foreach ($OrderArray as $SpecialOffers) {
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_WADAspecial_offers = "UPDATE special_offers SET Order = ". $start ." WHERE OffersID = " . intval($SpecialOffers[0]);
$WADAspecial_offers = mysql_query($query_WADAspecial_offers, $PowerCMSConnection) or die(mysql_error());
$start++;
}
}
?>
<?php
$curOrder = 0;
?>
<?php do { ?>
<?php
$curOrder ++;
?>
<tr class="<?php echo($WARRT_AltClass1->getClass(true)); ?>">
<td width="30" class="WADAResultsTableCell" style="text-align:center;"><label for="Order"></label>
<input type="text" name="Order_<?php echo($curOrder); ?>" value="<?php echo($curOrder); ?>" style="width:25px; text-align:center;">
<input type="hidden" name="OffersID_<?php echo($curOrder); ?>" value="<?php echo($row_WADAspecial_offers['OffersID']); ?>">
Any light you may be able to shed on what and where I am going wrong gratefully received. If you need any files or access just let me know.
Cheers
Jamie