phpretard Posted May 12, 2008 Share Posted May 12, 2008 This Code Only Displays One Array Value. Icant figure out where to put the $a++ if that is what I am Suppost to do. $a=0; foreach ($_SESSION as $lineItem => $val){ echo" <table border=1 width=100%> <tr> <td> ".$_SESSION[$lineItem][$a]['Item']." </td> </tr> </table>"; } Array ( [myusername] => Administrator [invoice_number] => 447425 [invoice_items] => Array ( [0] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 226.97 [Quantity] => 100 [item] => Tri-Fold-Brochure [Description] => Full Color | Front And Back ) [1] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 115.98 [Quantity] => 100 [item] => Rack-Cards [Description] => Inventory Sheet ) [2] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 135.98 [Quantity] => 100 [item] => Flat-Invitation [Description] => Signature Cards ) [3] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 175.98 [Quantity] => 100 [item] => Letterhead [Description] => Welcome Letter Standard Paper ) ) ) I need to display all of the ".$_SESSION[$lineItem][$a]['Item']." Any Help? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 12, 2008 Share Posted May 12, 2008 i think you want this.. foreach ($_SESSION['invoice_items'] as $item_values){ echo" <table border=1 width=100%> <tr> <td> {$item_values['Item']} </td> </tr> </table>"; } Quote Link to comment Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 Sweeeeet! Just one more thingy. How do I display the [0] or the [1] etc... part of this: [0] => Array I think it's the $key but for the purpose of unseting peices of the array i need to identify that value. Quote Link to comment Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 Maybe a better question would be how do I unset... [3] => Array ( [COName] => ENS Metals and Jewelry, Inc. [Cnumber] => 156882 [Price] => 175.98 [Quantity] => 100 [item] => Letterhead [Description] => Welcome Letter Standard Paper ) ...if I needed to. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 12, 2008 Share Posted May 12, 2008 If you use a for loop instead of a foreach loop, you have the index: <?php for($i=0;$i<count($_SESSION['invoice_items']);$i++) { echo" <table border=1 width=100%> <tr> <td> ".$_SESION['invoice_items'][$i]['Item']." </td> </tr> </table>"; ?> Ken Quote Link to comment Share on other sites More sharing options...
phpretard Posted May 12, 2008 Author Share Posted May 12, 2008 That does't display anything (BTW i did see the "}" missing) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 12, 2008 Share Posted May 12, 2008 Did you see I misspelled $_SESSION as $_SESION? (flaky keyboard) Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.