Jump to content

taking 1 from a mysql field when above a certain value. ???


Orionsbelter

Recommended Posts

Hi i have the following code

 

$orderFetch->order="3";
mysql_query("UPDATE `categories` SET order=order-1 WHERE `order` > $orderFetch->order");

 

i wish to minus -1 from all the "order" fields in categories that are over a certain value i.e 3. But however this code is not working can anyone tell me where i'm going wrong?

 

thank you

Add logic to check for query success/failure, and (at least while in development) echo the query string along with mysql_error() on failure. On success check that mysql_affected_rows() is > 0.

`order` is a MySQL reserved word. Either change the name of the field, or enclose `order` in backticks whenever it appears in a query string as a field/table/database name.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.