Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

tidying up mysql results with php

I have a PHP code to show info of the rows with parameter 0 in "seccion" field from a mysql database.

The code looks like this:

while($row = $result->fetch_assoc()) {
  if ($row['seccion']==="0") {
    $finalmsg = nl2br($row['msg']);
    echo "<div class='box-msg'><p>" . $finalmsg . "</p></div>";
  }
}

Now that I've got more info in my database I will need to add pagination for the results... I was thinkin about adding 2 variables before the code, "total_selected" for the number of rows with parameter "0" in "seccion" and "display_number" for set the number of results to show in the page. So then I would be able to make a division with the "total_selected" and "display_number" to get the numbers of pages. And the problem or the things that I don't know how to do are these:

  • How can I get or count the number of lines with "0" in field "seccion"?
  • How can I check if the tenths are not 0? (so I can add one more page)
  • Do the code that I am using now work for only a number of rows ("display_number") starting at a certain number (e.g. display_number*2 for page 3).

Thanks to all for your time.

Comments