php - for loop repeating same size row in shopping cart page? -


i have shoppingcart page loop count session cart problem i'm retrieving sizes values mysql database for loop repeating single row again , again every products want display different sizes every products? please me in advance?

select size query mysql table

function get_size($id){ $result=mysql_query("select mywishlist.`sizes` mywishlist order id desc ")  or die("id problem"."<br/><br/>".mysql_error()); while($row=mysql_fetch_assoc($result)){ return $row['sizes'].'<br>'; } } 

shopping cart loop condition

<?php if(is_array($_session['cart'])){  $max=count($_session['cart']); for($i=0;$i<$max;$i++){ $id=$_session['cart'][$i]['id']; $q=$_session['cart'][$i]['qty']; $product=get_product_name($id); $image=get_product_image($id); $ids=get_id($id); $itemcode=get_itemcode($id); $size=get_size($id); if($q==0) continue; ?>  <div style="margin-left: -20px;"> <?php echo $sizes; ?> </div> <input type="hidden" name="size[]" value="<?php echo $sizes; ?>" /></td> <?php } } ?> 

even have tried of session still same problem

$sizes=$_session['sizes1']; 

my mysql table picture have 2 different sizes

enter image description here

**shopping cart page ** enter image description here

when return loop exits

try:

function get_size($id){ $sizes = array(); $result=mysql_query("select mywishlist.`sizes` mywishlist order id desc ")  or die("id problem"."<br/><br/>".mysql_error()); while($row=mysql_fetch_assoc($result)){ $sizes[] =  $row['sizes']; } return implode('<br>', $sizes); } 

i think spotted error still use code provided above

and make following change in shopping cart loop condition

 $sizes=get_size($id); // instead of $size=get_size($id); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -