Well, when you are new to something, you will need people's help in some way or another (directly asking questions or reading guides made by others) to go through the initial learning process. So don't feel bad for asking questions
Alright, when we want to do something, we should write down the process. It will make it easier to translate into coding.
1) We take all the adoptables owned by the person
2) We set a limit of how many adoptables will be displayed per row
3) With the number of adoptables (for example, 30) and the limit (for example, 5), we can get the number of rows our table will have (30/5 = 6)
5) To go through all rows, we need a for() cycle.
6) We need to display 5 adoptables per row, so we make an internal for() cycle
PHP Code:
use Resource\Collection\ArrayList;//add this to use ArrayLists
//rest of code here
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($this->lang->title);
$pagination = $this->getField("pagination");
$stmt = $this->getField("stmt")->get();
if($stmt->rowCount() == 0){
$document->addLangvar($this->lang->empty);
return;
}
//new code starts here:
$adoptTable = new Table("adopttable", "", false);
$numAdoptsPerRow = 5;
$total = $stmt->rowCount();
$numTotalRows = ceil($total / $numAdoptsPerRow);
$index = 0;
//this is a copy from the table in the Daycare:
for($row = 0; $row < $numTotalRows; $row++){//for cycle to write the rows
$aRow = new TRow("row{$row}");
for($column = 0; $column < $numAdoptsPerRow; $column++){//internal for cycle for the columns
$adopt = new OwnedAdoptable($stmt->fetchColumn());
$cell = new ArrayList;
$cell->add(new Comment("<a href='/levelup/click/{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a>"));
$cell->add(new Comment("<b>Name:</b>{$adopt->getName()}"));
$cell->add(new Comment("<b>Gender:</b>{$adopt->getGender()}"));
$cell->add(new Comment("<b>Clicks:</b>{$adopt->getTotalClicks()}"));
$aCell = new TCell($cell, "cell{$index}");
$aCell->setAlign(new Align("center", "center"));
$aRow->add($aCell);
$index++;
if($index == $total) break;
}
$adoptTable->add($aRow);
}
$document->add($adoptTable);
$document->addLangvar($pagination->showPage());
}