How about this for an insight?
UPDATE tblposts SET rating = views + likes + tagcount + dcount + $value WHERE status = 'live';
This means: "For each status that is currently
live, make the column
rating be the sum of
dcount and a php variable". Pretty much a translation of your php code.
This removes the need for any selects and loops. Let the DB do the work for you.
Since you are using
mysql_*, I'm not even going deep about security and that stuff. I'll just leave this here for reference:
How can I prevent SQL-injection in PHP? - & - Booby Tables
- Why shouldn't I use mysql_* functions in PHP?
And take care when using
do..whilelike that. Since it only checks after running at least once, you might get some
warningin case there are no results.