mySQL PHP print results from multiple rows -


this beginner php/sql question.

basically, have database looks 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 unique id
  • has content
  • is written member unique member_id
  • has unique hotscore calculated cron job using reddit's hotscore ranking algorithm

my question is: how can top 3 scores , display data these poems?

the php code have far this:

if ($rankerrows = $mysqli->prepare("select * poems order poem_hotscore desc")) {      $rankerrows->execute();     $rankerrows->store_result();       while ($row = mysqli_fetch_assoc($rankerrows)) {         print_r($rankerrows);     }  } 

how data each row? know how 1 row, i'm not sure how 3 rows.

thanks in advance advice.

the data each row in $row, print that, not $rankerrows.

while ($row = mysqli_fetch_assoc($rankerrows)) {     print_r($row); } 

and can add limit 3 clause end of query return top 3 rows.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -