php - how do i echo each multiple same result with different rows -
i have page echo same result multiple times according quantity example:
id | qty | name 1 | 4 | gun 2 | 3 | jet 3 | 2 | cup result: gun gun gun gun jet jet jet cup cup
my problem how add variable echo differents rows each of multiple same result example following:
id | qty | name 1 | 4 | gun 2 | 3 | jet 3 | 2 | cup
my expected result should this:
gun row1
gun row2
gun row3
gun row4
jet row1
jet row2
jet row3
cup row1
cup row2
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></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