Retrieving information from tables
Previous  Next

Now we have created the database myshop and the table phonebook within it; we have added some rows to the phonebook table and we are going to retrieve the table content.

<?php
            include 'gladius/gladius.php';

            $G = new Gladius();

            // call the database selection method
            $G->SelectDB('myshop') or die($G->errstr);

            // execute a SELECT statement and fetch all the rows
            $rsa = $G->GetArray('SELECT * FROM mytable');

            // iterate through all rows
            foreach ($rsa as $row) {

                        // print the row array
                        print_r($row);

            }

?>

The output will be:

Array
(
    [0] => Array
        (
            [name] => Giuseppe
            [surname] => Albertini
            [phone] => 2805-2002
        )
    [1] => Array
        (
            [name] => Gabriele
            [surname] => D'Annunzio
            [phone] => 2805-2003
        )

)