RE: [PHP] Generating percentages of numbers

From: Date: Wed, 21 Feb 2001 22:54:09 +0000
Subject: RE: [PHP] Generating percentages of numbers
Groups: php.general 
Request: Send a blank email to php-general+get-41075@lists.php.net to get a copy of this message
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:blake@webintention.com] Sent: Wednesday, February 21, 2001 4:15 PM To: php-general@lists.php.net 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?

« previous php.general (#41075) next »