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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.