Forum Moderators: coopster
Also, I would like this script to add 1 to every number in a certain column in every row, all I can get thus far is it adds 1 to the first row then updates the rest of the rows with the first row value, I want it to add 1 to each unique number in each row
so
if we had three rows
245
352
634
they would become
246
353
635
not
246
246
246
Thanks all
I do not have the code on me because I am not at home but when I get home tomorrow evening I will post it, if you have any suggestions until that time please feel free to post them.
##Connect to User Database
$uresult = mysql_query("SELECT * FROM user_char", $link) or die ("query 1: " . mysql_error());
$urow = mysql_fetch_array($uresult) or die ("query 2: " . mysql_error());
while{
$turns = ++$urow[turns];
##Update the database
$eresult = mysql_query("UPDATE user_char set turns = '$turns' where username = '$urow[username]'", $link);
}
if ($eresult == TRUE)
{
echo 'Updated successfully';
}
else
{
echo 'turn update failed';
}
But it is taking the value from the first row and adding 1 to it then inserting that value into every other row.
Anyone know what I am doin wrong?
I guess if your database isn't that large your way isn't an issue, but if your site gets too big you will need a more efficient way.
:-)