This is a beginner PHP/SQL question.
Basically, I have a Database that looks like this
Poem_id | Poem_content | Poem_by | Poem_hotscore
------------ ----------------- ----------- -----------------
1 | Blah Bleh<br>B.| 4 | 5342.3920349
------------ ----------------- ----------- -----------------
7 | Blah Bluu<br>F.| 4 | 5003.3920382
------------ ----------------- ----------- -----------------
9 | Blerp Bloop Foo| 34 | 4300.7281209
Each poem
- Has a unique
id - Has content
- Is written by a member with a unique
member_id - Has a unique
hotscorecalculated by a Cron Job using Reddit's hotscore ranking algorithm
My question is: How can I get the top three scores and display all the data from these poems?
The PHP code I have so far is this:
if ($rankerrows = $mysqli->prepare("SELECT * FROM poems ORDER BY poem_hotscore DESC")) {
$rankerrows->execute();
$rankerrows->store_result();
while ($row = mysqli_fetch_assoc($rankerrows)) {
print_r($rankerrows);
}
}
How exactly do I get the data from each row? I know how to do it for one row, but I'm not sure how to do it for 3 rows.
Thanks in advance for any advice.
$row.