How do i echo diffrent rows to each same multiple result -
i have page echo same result multiple times according quantity example:
id | qty | name 1 | 4 | gun 2 | 3 | jet 3 | 5 | cup result: gun gun gun gun jet jet jet cup cup cup cup cup
my problem how add variable echo differents rows each of multiple result example following:
id | qty | name | code 1 | 3 | shoe | $query 2 | 2 | boy | $query 3 | 3 | tip | $query
my result set should this:
shoe each different result shoe each different result shoe diffrent db row result boy diffrent db row result boy diffrent db row result
tip diffrent db row result tip diffrent db row result tip diffrent db row result
i have tried code:
<?php session_start(); include "mysql.php"; ?> <?php $cartoutput = ""; $product_id_array = ''; if (isset($_session["cart_array"]) || count($_session["cart_array"]) > 1) { // start each loop $i = 0; foreach ($_session["cart_array"] $each_item) { $item_id = $each_item['item_id']; $qty = $each_item['quantity']; } $sql = mysql_query("select * products id='$item_id' order id"); while ($row = mysql_fetch_array($sql)) { $product_name = $row["product_name"]; // create product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // dynamic table row assembly ($b = 1; $b <= $each_item['quantity']; $b++) { $cartoutput .= "<tr>"; $cartoutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>'; //$cartoutput .= '<td>' . $each_item['quantity'] . '</td>'; $cartoutput .= '</tr>'; $i++; } } ?> //show each multiple variable diffrent code fetch query <?php $query_select = ("select code, diffrent_codes name='$product_name' order id asc"); $result_select = $mysqli_query($query_select) or die(mysql_error()); $rows = array(); while($row = mysql_fetch_array($result_select)) $rows[] = $row; foreach($rows $row){ $code = $row['code']; } echo $cartoutput$code; } ?>
how can achieve this
Comments
Post a Comment