Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2008
    Posts
    446
    Thanks
    23
    Thanked 5 Times in 5 Posts

    problems creating multi dimensional array from db

    **** 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)
    PHP Code:
    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
    Last edited by surreal5335; 08-05-2011 at 09:56 AM.

  • #2
    Regular Coder
    Join Date
    May 2008
    Posts
    446
    Thanks
    23
    Thanked 5 Times in 5 Posts
    problem fixed
    Last edited by surreal5335; 08-05-2011 at 09:55 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •