...

View Full Version : problems creating multi dimensional array from db



surreal5335
08-04-2011, 07:45 AM
**** Problem fixed **** (dont know how to delete a thread)


I am trying to create a multi-dimensional array populated via mysql query. I am looking to have this result:

array(
1 => array(
'0000-00-00' array(
0 => '1',
1 => '2'
)
),
2 => array(
'0000-00-00' array(
0 => '3',
1 => '4'
)
)
)

the '0000-00-00' is meant to represent a date stamp value saved in the database.

The numbers in the nested arrays represent the id of the rows which have the same date stamp.

Here is what I have so far:

$hist_array = date stamp values put into an array
$ids_array = array of id values pulled from the same table
(both of these work correctly)

foreach($hist_array as $match)
{

foreach($ids_array as $id) // group matches of dates into nested arrays
{
$match_query = "SELECT post_date_update FROM posts WHERE post_id='".$id."'";
$result = $Database->query($match_query);
//$row = mysql_fetch_assoc($result);


$row = $result->fetch_array(MYSQLI_NUM);
if($match == $row[0])
{
//$hist_multi_array[$row[$match]][] = $row[$id];
$value = $row[0];
$hist_multi_array[] = $value;
} //end if

} //end foreach($ids_array as $id)

}// end foreach($hist_array as $match)

I appreciate the help

surreal5335
08-05-2011, 06:01 AM
problem fixed



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum