Pagnation with Redbean

38 views
Skip to first unread message

Brian Flores

unread,
Jul 29, 2022, 2:58:17 PM7/29/22
to redbeanphp

I am using RedbeanPHP ORM to design a personal text based web game.

So what I am trying to do is list 10 Rows of users from the Database Ordered by my rank field.

I will have a list of users. I want to put in a button for the next page that will allow the user to change to the next page of 10 users.

Right now it displays my list of users but is not ordering the list according to rank. Also I need to figure out how to only display 10 users and add a next page button that displays the next 10.


My code is:

[code]

<?php $userCount = R::count( 'users' ); // Get RedBean User Count echo "Player Count is Currently: ".$userCount."<br />"; // Display how many users are in the database for($i = 1; $i <= $userCount; $i++) { // Print Rows using the Count     $galaxyuser = R::getRow("SELECT * FROM `users` WHERE `id` = '$i' ORDER BY `rank` ASC"); // Get Each User Info //Get User Information into Variables $pt = $galaxyuser['planettype']; $money = $galaxyuser['money']; $covtroops = $galaxyuser['covtroops']; $atktroops = $galaxyuser['atktroops']; $deftroops = $galaxyuser['deftroops']; $covlvl = $galaxyuser['covlvl']; $yourcovstrength = ($data['covtroops']*$data['covlvl']*3000); $theircovstrength = ($galaxyuser['covtroops']*$galaxyuser['covlvl']*3000); // Determine Whether Your Covert Strength is higher than theirs so you can see what resources are onhand. if($yourcovstrength >= $theircovstrength){    $covmoney = number_format($money); $size = number_format($galaxyuser['atktroops']+$galaxyuser['deftroops']+$galaxyuser['untrained']+$galaxyuser['miners']+$galaxyuser['covtroops']);     }else{     $covmoney = "?????????";     $size = "?????????"; } // Get Planet Image Name Depending on Planet Type. if($pt==1){         $pl = "planet1_small";     }elseif($pt==2){         $pl= "planet2_small";     }elseif($pt==3){         $pl = "planet3_small";         }elseif($pt==4){         $pl = "planet4_small";     }elseif($pt==5){                     $pl = "planet5_small";     }elseif($pt==6){         $pl = "planet6_small"; } //Print User Information print "<div id='galaxyuser'>";                     print "<img src='images/".$pl.".png' />"; print "<a href='player.php?id=".$galaxyuser['id']."'>".$galaxyuser['username']."</a><br />"; print "<span id='borderleft'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Army Size:".$size."</span><br />"; print " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Onhand Crystals:".$covmoney."<br />"; print "<a href='attack.php?id=".$galaxyuser['id']."' class='button'>Crystal Attack</a> | <a href='civattack.php?id=".$galaxyuser['id']."' class='button'>Civillian Raid</a> | <a href='intellegence.php?id=".$galaxyuser['id']."' class='button'>Intellegence Report</a>"; print "<br/><br/></div>"; } ?>

[/code]

Thank you for any help regarding this subject.
Brian

Reply all
Reply to author
Forward
0 new messages