get specific keys from database
I'm trying to get some specific keys and values from the database. My
database entries look like so:
id | name | description | value
------------------------------------------
1 | lang | default language | en
2 | date | date format | YYYY-MM-DD
I want to echo only my name and value fields. I've tried using a nested
foreach loop, like so:
foreach($details as $key => $value)
{
foreach($value as $index => $row)
{
echo $index . " / " . $row . "<br />";
}
echo "<br />";
}
But that only echos:
id / 1
name / lang
description / default language
value / en
id / 2
name / date
description / date format
value / en
However, when I add an offset, like so: $index[1], I get this like a
instead of name, or e instead of description.
I've previously worked from while loops using mysql_fetch_array, but this
would give me a repeated element (say a <tr>) whereas I simply need to
extract the value of the field because this will be used to build a form
for the user to manage.
Would anyone have a suggestion or different approach for me to do
something of the sort ?
No comments:
Post a Comment