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.
Getting One Value from a multidemensional array
Moderator: General Moderators
Re: Getting One Value from a multidemensional array
Code: Select all
//Initiate an array
$fieldsArr = array();
while ($row = mysql_fetch_assoc($qColumnNames)) {
$fieldsArr[] = $row['Field'];
}
Re: Getting One Value from a multidemensional array
ahhhh
Much thanks my brother.
Much thanks my brother.