Getting One Value from a multidemensional array
Posted: Tue Mar 03, 2009 12:00 pm
Good evening ladies and gentlemen
Im writing a script that needs to get the names of each column from a sql table
Currently I have this
$qColumnNames = mysql_query("SHOW COLUMNS FROM sometable",$link) or die("mysql error");
$numColumns = mysql_num_rows($qColumnNames);
echo "
";
while ($row = mysql_fetch_assoc($qColumnNames)) {
print_r($row);
}
echo "
";
Which gives me thi output
Array
(
[Field] => id
[Type] => int(10) unsigned
[Null] => NO
[Key] => PRI
[Default] =>
[Extra] => auto_increment
)
Array
(
[Field] => Yes
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => No
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => maybe
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => who_care
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
What I want to do is take each value of [Field] and add that to a new array, Can anyone show me how to do that?
Thanks.
Im writing a script that needs to get the names of each column from a sql table
Currently I have this
$qColumnNames = mysql_query("SHOW COLUMNS FROM sometable",$link) or die("mysql error");
$numColumns = mysql_num_rows($qColumnNames);
echo "
";
while ($row = mysql_fetch_assoc($qColumnNames)) {
print_r($row);
}
echo "
";
Which gives me thi output
Array
(
[Field] => id
[Type] => int(10) unsigned
[Null] => NO
[Key] => PRI
[Default] =>
[Extra] => auto_increment
)
Array
(
[Field] => Yes
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => No
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => maybe
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
Array
(
[Field] => who_care
[Type] => text
[Null] => NO
[Key] =>
[Default] =>
[Extra] =>
)
What I want to do is take each value of [Field] and add that to a new array, Can anyone show me how to do that?
Thanks.