Calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am not sure if this is possible or not or in what
format etc.  Maybe it's a PHP, mysql or even a
JavaScript thing.  But thought I'd post here and see
if people are aware if it is possible for what I want
to do.  I have searched alot on the net and yet have
not come accross what I am looking for, so posting
here may get me pointed in the right direction.  Okay
here is what I wanna do. :)

I have a list of users in multiple tables in the one
database.  Each user has a field named 'score'.  As
the table numbers go higher generally the score goes
higher but never lower than the previous table.  There
are 22 tables named 1 to 22.  So an example is below:

table 1:
User: bob
Score: 7

table 2:
User: bob
Score: 10

table 3:
User: bob
Score: 16

....

So the scores go up and never down from the previous
table value.  Now what I want to output on a page is
not 7, 10, 16 but output the difference from the
current table and the table before it.  So obviously
table 1 would not be changed from 7 but table 2 would
need to output 3 and table 3 would output 6.  So I
need to output not the value but the difference
between the current table and the table before it and
if there is no table before it the value would be the
same or in other words the value minus 0.

Is there either a mysql query I can use for this or
would I use a JavaScript bit of code to work out the
difference and output it?

The code will need to connect to the database and
retrieve values and users from all 22 tables and cores
and somehow output the difference, is this possible?

Table 22 has the total amount after all tables, So I
don't need a total figure worked out.  (E.G. Aadding
all the scores together)

Is it possible, or a bit complicated?

I know this is a bit of a pain but already the scores
have been worked out, I should of created another
field to get the table score for that round from the
start and keep it but I did not think of that earlier
in the year.

If it's tto much work I wont bother about it, but
thought I'd ask and see if anyone can help.

Thanks!

Jerry

http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux