I have an multi-dimensional array that I am trying to build from an SQL query. I am having trouble adding the id
in the inner array.
Code:
$checkboxes = "SELECT id, name FROM review_sites WHERE active=1 ORDER BY name ASC";
$result = mysql_query($checkboxes) or die(mysql_error());
$names = array();
while ($row = mysql_fetch_array($result)) {
$names[]['name'] = $row['name'];
}
Currently the Array looks like:
Array
(
[0] => Array
(
[name] => 411.ca
)
[1] => Array
(
[name] => AutoMD
)
I Need the array to look like this:
Array
(
[0] => Array
(
[id] => 4
[name] => 411.ca
)
[1] => Array
(
[id] => 9
[name] => AutoMD
)