php-db | 2000121
Date: 12/05/00
- Next message: Adv. Systems Design: "[PHP-DB] dataflex anyone"
- Previous message: Leonardo Rezende: "[PHP-DB] ORACLE8 + APACHE + WINDOWS + PHP4"
- Next in thread: Alexey Borzov: "Re: [PHP-DB] auto incrementing rows from query.."
- Reply: Alexey Borzov: "Re: [PHP-DB] auto incrementing rows from query.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm trying to determine the percentile value of where a row lies in a
query.. hard to explain, but I'll try.
I do a select all of my table, sorting it by SCORE. I want to find the
position of a certain row in that select all, get that row #, and then I can
calculate the percentile fine by dividing that position into the total # of
rows, then multiplying by 100.
my code is like:
$querysetup = "SELECT SCORE, PID from pictures where VOTES > 100 order by
SCORE DESC";
$query = mysql_query($querysetup);
$num = ??? position of that row, don't know how to get this.
$numrows = mysql_num_rows($query);
if (!mysql_data_seek($query, $num)) {
printf ("Cannot seek to row %d\n", $num);
exit();
} else {
if ($row = mysql_fetch_array($query)) {
echo "<br>";
echo $row[SCORE];
echo "<br>";
echo $row[PID];
}
}
I thought doing a query like:
SELECT SCORE, PID, RANK as (RANK + 1) from pictures where VOTES > 100 order
by SCORE DESC;
would work, but it doesn't.. using an auto_increment field in the table
won't work since it will be all jumbled by the ORDER BY .. so how do I most
efficicently get that row position?
Thanks,
Chad Day
Beach Associates
When I speak german... I think german in my head... but like...Do skript
kiddies see a w40l3 8uncha 1's and 0's and 3's and 4's and 7's in their
h34d'5 w43n t43y R +a1k1n6 ? -- SirStanley
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Adv. Systems Design: "[PHP-DB] dataflex anyone"
- Previous message: Leonardo Rezende: "[PHP-DB] ORACLE8 + APACHE + WINDOWS + PHP4"
- Next in thread: Alexey Borzov: "Re: [PHP-DB] auto incrementing rows from query.."
- Reply: Alexey Borzov: "Re: [PHP-DB] auto incrementing rows from query.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

