View Full Version : unable to echo array

08-04-2008, 10:42 AM
This is an on going problem.

//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)){

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/>";
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.

08-04-2008, 10:53 AM
mysql_fetch_array($itemids['item_id']) this function expects the argument to be a mysql_query result. Check the output of

echo $itemids[0]['item_id'];

08-04-2008, 11:13 AM
Thanks for your help. The output of

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?

08-04-2008, 11:26 AM
echo "<br/>".$itemids[$i]['item_id'] ;
http://www.codingforums.com/showthread.php?t=145737 :confused:

08-04-2008, 11:40 AM
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.

08-04-2008, 12:14 PM
(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!