Reputation: 856
Using Medoo how do I echo the values from the select query currently this is what I am doing using the example from the docs.
$data = $database->select('names', [
'name','nameId'
], [
'nameId' => 50
]);
echo json_encode($data);
the result is:
[{"name":"Allen","nameId":"50"}]
How can I echo each one without json_encode?
I have tried:
$data['name']
But that doesn't work.
Upvotes: 1
Views: 831
Reputation: 542
If it's one row you're looking to fetch, use Get instead of Select
$names = $db->get('names',['name','nameId'],['nameId'=>50]);
then use
$name = $names['name'];
$nameId = $names['nameId'];
although you don't need the nameId since your condition is based on it so simply:
$name = $db->get('names','name',['nameId'=>50]);
Upvotes: 3
Reputation: 433
Loop and print.
foreach ($data as $row) {
// echo code here...
// echo $row['name'];
}
http://php.net/manual/en/control-structures.foreach.php
Upvotes: 2