...

View Full Version : unable to echo array



irenaught
08-04-2008, 09: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)){
$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.

abduraooft
08-04-2008, 09: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'];

irenaught
08-04-2008, 10: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?

abduraooft
08-04-2008, 10:26 AM
for($i=0;$i<count($itemids);$i++)
echo "<br/>".$itemids[$i]['item_id'] ;
http://www.codingforums.com/showthread.php?t=145737 :confused:

irenaught
08-04-2008, 10: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.

abduraooft
08-04-2008, 11:14 AM
(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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum