My idea is so easy it can't be right but here goes.

Couldn't you read the total and page count into an array, the divide array
values 1-3 by array value 0 and multiply that by 100?  In other words:

$row[0] = 1000;
$row[1] = 500;
$row[2] = 250;
$row[3] = 250;

array[1]/array[0] = 0.5 * 100 = 50
array[2]/array[0] = 0.25 * 100 = 25
array[3]/array[0] = .25 * 100 = 25

Like I said it's too simple but I haven't tested it so I'm probably missing
something.

John Guynn

This email brought to you by RFCs 821 and 1225.


-----Original Message-----
From: Blake S. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 21, 2001 4:15 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Generating percentages of numbers


I have a database of numbers:

TOTAL HITS: 1000
PAGE 1: 500
PAGE 2: 250
PAGE 3: 250

How can I query these numbers and display back a percentage number? For
instance with the numbers above:

PAGE 1: 50%
PAGE 2: 25%
PAGE 3: 25%

Or is their a process by which to store numbers for easily getting this to
work?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to