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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    unable to echo array

    This is an on going problem.

    PHP Code:
    //this query should get all stock items added to order by user
        
    $current_order_qry "SELECT item_id FROM orderitems WHERE order_id= $oid[order_id] ORDER BY item_id";
        
    $order_result mysql_query($current_order_qry) or die ("Cannot get items on order: ".mysql_error());
                  
            while(
    $orderitems mysql_fetch_array($order_result)){
        
    $itemids[]=$orderitems;
        }
        

    echo 
    "Order # \".$oid[order_id].\" is now complete please click Invoice Version at the bottom of the page to see the final invoice and print it.";

    echo 
    "<br/>";
    while(
    $row=mysql_fetch_array($itemids['item_id']))
            {
            echo 
    "The items on the order are".$row['item_id'];
        } 
    The variable "$itemids" when used with a print_r statement contains all the data i need. It is a list of item ids. I need to use them independently afterwards so they need to be strings individually. Please help me it's been three days I need this data. The code above outputs nothing Ive tried so many things and had some advice already but nothing works. Any help would be great.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Code:
    mysql_fetch_array($itemids['item_id'])
    this function expects the argument to be a mysql_query result. Check the output of
    PHP Code:
    echo $itemids[0]['item_id']; 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your help. The output of
    PHP Code:
    echo $itemids[0]['item_id']; 
    is the first item of the array but now how do i get a list of all of them auto generated based on how many there is on each order?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    PHP Code:
    for($i=0;$i<count($itemids);$i++)
        echo 
    "<br/>".$itemids[$i]['item_id'] ; 
    mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    irenaught (08-04-2008)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If you think it's annoying having to tell me twice how to do it imagine me having tried that this morning and somehow messing it up (I can't see any difference butone works and one doesnt???) then I spent all day trying to figure it out and now the same thing you said this morning just worked... Arrrrghh lousy php. Anyways thanks a lot for your help. You're my new hero.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Quote Originally Posted by irenaught
    (I can't see any difference butone works and one doesnt???)
    lol, I just copied this from the the other one , anyway you're welcome!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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