php - How to echo the same item from MySQL database multiple times with each different query -
how echo same item mysql database multiple times each different query. example following:
catt | qty | name | code wap | 3 | shoe | $query boy | 2 | net | $query tip | 3 | phon | $query
my result set should this:
wap shoe 113zu1 wap shoe 125dj1 wap shoe 125332 boy net 11331 boy net 13wa2 tip phon dej21 tip phon 5waja7p2 tip phon 532j3
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++; } } ?> //output each 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; } ?>
my $cartoutput$code
should output different $code according each session quantity variable
Comments
Post a Comment