tags:

views:

42

answers:

4

I would use only a single query:

$sql = "UPDATE gallery SET order = (order+1) WHERE id_categ = ".$id;
$res = mysql_query($sql);

...

Is it possible?

+3  A: 

mysql_affected_rows() should to the job.

Copied from the manual:

<?php
mysql_query("UPDATE mytable SET used=1 WHERE id < 10");
printf ("Updated records: %d\n", mysql_affected_rows());
// Prints: "Updated Records: 10"
edorian
Guess it'll be 9, because the first id will be 1, not 0.
GuidoH
+5  A: 
Sarfraz
+2  A: 

You can have a look at something like

astander
+1  A: 

Yes, just use

mysql_affected_rows()

after your query.

$sql = "UPDATE gallery SET order = (order+1) WHERE id_categ = ".$id;
$res = mysql_query($sql);
$rowsAffected = mysql_affected_rows();

Edit: Damn, you guys are fast ;)

TheCandyMan666