Results 1 to 2 of 2

Thread: multidimensional array from loop

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default multidimensional array from loop

    ive always had issues with arrays. can anyone help out how to push 2 values into an array so that i can echo them later please?
    Code:
    $arr = array();
    
    $query0 = "SELECT navid, type FROM mytable WHERE id='$id' ORDER BY navDisplayNum ASC";
    $result0 = mysql_query($query0) or die (mysql_error());
    
    while ($dataList = mysql_fetch_assoc($result0)) {
    	$navid = $dataList['navid'];
    	$type = $dataList['type'];
    
    	$arr[] = array($type,$navid);// this doesnt work
    
    }
    echo $arr;
    Last edited by ggalan; 02-11-2012 at 12:27 AM.

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    That looks like that should work. But using echo on the $arr is wrong, you need to use print_r() if you want to see what the array holds.

  3. The Following User Says Thank You to fastsol1 For This Useful Post:

    ggalan (02-11-2012)

Bookmarks

Posting Permissions

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