Jump to content

PHP & MYSQL Update Incremented Value


RagingEagle

Recommended Posts

Hi,

 

I'm having a problem incrementing a value and putting it into an Update statement, my code is as follows:

 

$CurrentRank = 1;

mysql_query("UPDATE The_Table SET Rank_Today = $CurrentRank");

$CurrentRank++;

 

What I want it to do is place the incremented number by $CurrentRank++; into Rank_Today, but it doesn't work and instead it counts every row in the table and puts that number in every Rank_Today column.  Anybody have any idea why I'm experiencing what I am? I've tried putting echo $CurrentRank; and it outputs the correct number to the page itself, but it doesn't send the right value to the database (as I said it sends the total counted number to the database, so if there are 30 rows it would place the number 30 in every Rank_Today column instead of going 1-30).

 

Any help would be greatly appreciated.

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.