Welcome Guest, Not a member yet? Register   Sign In
Entity class - loop 20 rows and iterate through columns in view
#6

(This post was last modified: 08-28-2021, 08:10 AM by ikesela.)

(08-28-2021, 12:31 AM)Corsari Wrote: WOW !

First of all, thank you for the help!

Cool, I'll try that this afternoon when at the PC.

How did you got the jsonSerialize() hint/idea? Thank you for this curiosity

if you use dd() to see detail, the entities will show two tabs: [properties , available methods] (FOUND HERE IN AVAILABLE METHODS)

(08-28-2021, 03:59 AM)Corsari Wrote:
(08-27-2021, 11:51 AM)ikesela Wrote: I try it and got answer :

PHP Code:
foreach ($tRows as $tKey):
        echo "<tr>";
      $tnewKey $tKey->jsonSerialize(); 
        foreach ($tnewKey as $key => $value){
            echo "<td>";
            echo $value;
            echo "</td>";
        }

        echo "</tr>";                        
    
endforeach; 

hello, as stated above, I tried it and it works ... though one weird thing happen


model
PHP Code:
public function listTickets($quantity$offset)
 {

 
$ticketModel = new TicketModel();

 
$data $ticketModel->findAll($quantity$offset);
      
        
return $data;




controller
PHP Code:
public function list($quantity$offset)
 {

 
$ticketModel = new TicketModel();

 
$ticketData $ticketModel->listTickets($quantity$offset);

 
$data = [];

 
$data['tRows'] = $ticketData;

 return 
view("Home/index"$data);

 } 

depite I browse myapp.local/home/list/25/0

they are printed ALL the 300 rows of records in the database

I mean, the resulting HTML table, doesn't have 25 rows, instead it has 300 rows

Wondering: how is this possible?.
Whilst if I use the original code at the begin of this thread, they only prints the expected 25 rows .. really confused about this behavior

How you define your routes? let see it ,
btw you can test directly data in controller dd(), to see if the result is correct before pass to view. do it step by step until found where the problem. also test query with external mysql client , suggest: HeidiSQL
Reply


Messages In This Thread
RE: Entity class - loop 20 rows and iterate through columns in view - by ikesela - 08-28-2021, 08:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB