While looping PHP array HTML table properties are missing after first row? -
i trying show shopping cart array in cart page in html table, after first row html table properties missing. mean after first row data not showing html table. what's wrong in code?
<?php if(is_array($_session['cart'])){ ?> <table border = "1"> <tr bgcolor="#ffffff" style="font-weight:bold"> <td>serial</td> <td>name</td> <td>price</td> <td>qty</td> <td>amount</td> <td>options</td> </tr> <?php $max=count($_session['cart']); for($i=0;$i<$max;$i++){ $pid=$_session['cart'][$i]['productid'].' el kit'; $q=$_session['cart'][$i]['quantity']; $amount = $_session['cart'][$i]['amount']; ?> <tr bgcolor="#ffffff"> <td><?php echo $i+1?></td> <td><?php echo $pid?></td> <td>$<?php echo $amount?></td> <td><input type="text" name="product<?php echo $pid?>" value="<?php echo $q?>" maxlength="3" size="2" /></td> <td>$<?php echo $amount*$q?></td> <td><a href="javascript:del(<?php $pid ?>)">remove</a></td> </tr> </table> <?php } } ?>
you </table>
repeated in each iteration of loop , try put after loop.
<?php if(is_array($_session['cart'])){ ?> <table border = "1"> <tr bgcolor="#ffffff" style="font-weight:bold"> <td>serial</td> <td>name</td> <td>price</td> <td>qty</td> <td>amount</td> <td>options</td> </tr> <?php $max=count($_session['cart']); for($i=0;$i<$max;$i++){ $pid=$_session['cart'][$i]['productid'].' el kit'; $q=$_session['cart'][$i]['quantity']; $amount = $_session['cart'][$i]['amount']; ?> <tr bgcolor="#ffffff"> <td><?php echo $i+1?></td> <td><?php echo $pid?></td> <td>$<?php echo $amount?></td> <td><input type="text" name="product<?php echo $pid?>" value="<?php echo $q?>" maxlength="3" size="2" /></td> <td>$<?php echo $amount*$q?></td> <td><a href="javascript:del(<?php $pid ?>)">remove</a></td> </tr> <?php } } ?> </table>
Comments
Post a Comment