Jump to content

Get data out of while loop


Bravat

Recommended Posts

Here is the while loop:

<?php 
require_once("../includes/initialize.php");
$sql="SELECT * FROM product WHERE product_id IN (";					
				foreach($_SESSION['cart'] as $id => $value) {
					$sql.=$id.","; }
				$sql=substr($sql, 0, -1).") ORDER BY model ASC";
				$query=mysql_query($sql);
				$totalprice=0;

				while($row=mysql_fetch_array($query)){						
					$subtotal=$_SESSION['cart'][$row['product_id']]['quantity']*$row['price'];
					$totalprice+=$subtotal;
				?>
					<tr>
                        	  <td><?php echo $row['model'] ?></td>
					    <td><?php echo $_SESSION['cart'][$row['product_id']]['quantity'] ?></td>
					    <td><?php echo  number_format($row['price'], 2, ',', '.');  ?>din</td>
					    <td><?php $cena = $_SESSION['cart'][$row['product_id']]['quantity']*$row['price'];
						echo number_format($cena, 2, ',', '.');  ?>din</td>
					</tr>
				<?php }	 ?>

 

How to get data out of the loop? I need it to be same as data echoed (this is the echo result: BFG 225/30 ZR 20 4 21.667,00din 86.668,00din).

 

Link to comment
https://forums.phpfreaks.com/topic/227683-get-data-out-of-while-loop/
Share on other sites

He already explained how.  Basically you set a variable ($content for example) and then capture everything your currently echoing into that variable instead ($content .= 'whatever') and then use that variable to setup the mailing, once the while loop is done.

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.