1

I wanted to know how can I fetch records from an array with different object keys in php?

Here is my array output result:

    Array
(
    [0] => Array
        (
            [0] => Alpha Project
            [name] => Alpha Project
        )

    [1] => Array
        (
            [0] => Bravo Project
            [name] => Bravo Project
        )

)

Please note that I am using ADODB database class in my project. This is the sample code of ADODB for populating results:

<?php

include('adodb/adodb.inc.php');

$server = 'localhost'; $user = 'root'; $password = ''; $database = 'some_database'; $driver = 'mysql';

$db = ADONewConnection($driver);
$db->debug = true;

$db->Connect($server, $user, $password, $database);

$result = $db->Execute('SELECT `name` FROM project;');

print "<pre>";
print_r($result->GetRows());
print "</pre>";

?>

1 Answers1

0

Here is example:

$Results = $result->GetRows();
foreach ($Results as $key => $value) {
    // print_r($value['name'])  ;
    $option .= '<option value="'.$key.'">'.$value['name'].'</option>';
}

echo '<select>' . $option . '</select>';