Search code examples
phpmysqlzend-framework

Echo raw query result in php


I want to print a variable data on UI page.

Below is my raw query :

$query = $db->rawQuery("SELECT last_modified,version,last_saved_by from tbl_templates order by id desc limit 5");

    print($query);

But it outputs:

Array (No data only displaying "Array" as string on the UI page)

Solution

  • Use php method print_r();

    echo '<table>';
    echo '<tr><td>last_modified</td><td>version</td><td>last_saved_by</td></tr>';
    foreach ($query as $row) {
        echo "<tr><td>{$row['last_modified']}</td><td>{$row['version']}</td><td>{$row['last_saved_by']}</td>";
    }
    echo '</table>';