I am able to set a id column in my table, using this sql code in phpmyadmin:
SET @i = 0;
UPDATE albums SET id=(@i:=@i+1);
this wil give each row in the id column a consecutive number. it might me very basic, but how do I run this code in PHP?
I tried:
mysql_query('SET @i = 0;
UPDATE albums SET id=(@i:=@i+1);');
but that doesn't do anything
Thanks for the advice! best Sam
mysql_query() sends a unique query (multiple queries are not supported),So that your code not works.You can try it with different mysql_query().
mysql_query('SET @i = 0');
mysql_query('UPDATE albums SET id=(@i:=@i+1)');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With