Is there a problem with the error in running the program?

<?php

class read
{
    private $data;

    function __construct()
    {
        if ($db = new DataBase()) {
            $this->data = $db->showData();
        }
    }

    function __toString()
    {
        $out = "";
        while ($this->data) {
            $out .= "<tr>";
            $out .= "</td>"".$this->data["id"].""</td>";
            $out .= "</td>"".$this->data["title"].""</td>";
            $out .= "</td>"".$this->data["u_id"].""</td>";
            $out .= "</td>"".$this->data["content"].""</td>";
            $out .= "</td>"".$this->data["time"].""</td>";
            $out .= "</tr>";
        }
        $out .= "</table></div>";
        return $out;
    }
}
Is there something wrong with this code? Running always goes wrong.

Php
Mar.12,2021

 function __toString()
{
    $out = '';
    $out .= '<tr>';
    foreach($this->data as $v)
    {
        $out .= "</td>'".$v."'</td>";
    }
    $out .= '</tr>';
    $out .= '</table></div>';
    return $out;
}

while($row=mysql_fetch_row){
   //do something
}

this does not cause an endless loop because the mysql_fetch_row function automatically modifies the index value.

in addition, the code of the landlord does not need to use a loop at all.

Menu