Jump to content

exploding arrays


Schlo_50

Recommended Posts

Hey guys,

 

I have some code which gathers information submitted from a form by users. The information is stored in an array separated by commas. I need to print out the data ($orderid and $quantity) stored in the array, but it needs to be exploded and displayed in two rows. At the moment when i print out the data a string separated by commas is displayed.

 

Any help?

 

if (isset($_POST['update']) && ($_POST['update']==="Review Order")) {

  $orderid = array();
  $quantity = array();
  $price = array();

  foreach($_POST['orderid'] as $id){
	$orderid[] = $id;
	$quantity[] = $_POST['quantity'][$id];
	$price[] = $_POST['price'][$id];
	$subtotals[] = $_POST['price'][$id] * $_POST['quantity'][$id];
                $total +=  $_POST['price'][$id] * $_POST['quantity'][$id];
	}


  
  $orderid = implode(',', $orderid);
  $quantity = implode(',', $quantity);
  $price = implode(',', $price);


   $_SESSION['Total'] = $total;
   $_SESSION['orderID'] = $orderid;
   $_SESSION['Quantity'] = $quantity;

print "<br /><br /><table width=\"300\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" class=\"main2\">
     <tr>
     <td><strong>Order Id</strong></td>
     <td><strong>Quantity</strong></td>
     <td><strong>Individual Price (£)</strong></td>
     </tr>
     <tr>
     <td>$orderid</td>
     <td>$quantity</td>
     <td>$price</td>
     </tr>
     </table><br /><br />";

     print "<span class=\"main2\">Total: £$total</span>";

 

Thanks for any help guys!

Link to comment
https://forums.phpfreaks.com/topic/92888-exploding-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.