Array
(
[0] => stdClass Object
(
[id] => 1
[name] => lady gaga
[age] => 25
[city] => new york
)
[1] => stdClass Object
(
[id] => 2
[name] => luna maya
[age] => 27
[city] => denpasar
)
)
The above is the result of this function
function get_data(){
$output = '';
$select = db_select('data_siswa','c')->fields('c')->execute()->fetchAll();
return print_r($select);
}
To get the data as a table, use this one:
function introo(){
$output = '<table>';
$output .= '<tr><th>Name</th><th>Age</th><th>City</th></tr>';
$select = db_select('data_siswa','c')->fields('c')
->execute()->fetchAll();
foreach($select as $key){
$output .= '<tr><td>'.$key->name ."</td><td>";
$output .= $key->age. "</td><td>". $key->city ."</td></tr>";
}
$output .= "</table>";
return $output;
}
Drupal Database Access
No comments:
Post a Comment