fugix wrote:do you want to display the keys or the values?
array($row->pid); would be array($row=>'pid');
<?php echo $k+1 ;?> would be <?php echo $k; ?>
i want to display like this no,item,price,quantity,total price
so i want display 1 item RM8.90 4 RM 40
2 item RM5 5 RM25
i just want to show the no of product in the cart..
but i dont know how to show this..
Code: Select all
<?php
$query = "SELECT * FROM cart WHERE id=$id";
$result = mysql_query($query);
if($row1= mysql_num_rows($result))
{ ?>
<table border="1"bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" width="500px">
<tr align="center">
<td width="100px" bgcolor="#eeee76"><font color="#000000">NO</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000">Item Name</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000">Unit Price(RM)</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000">Quantity</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000">Total Price(RM)</font></td>
</tr>
<?php
while($row=mysql_fetch_object($result))
{
?>
<tr>
$item = array($row=>'pid');
<?php foreach ($item as $k => $cartids){ ?>
<td width="100px"> <font color="#000000"><?php echo $k ;?></font></td>
<?php }?>
<td width="100px"> <font color="#000000"><?php echo $row->pname;?></font></td>
<td align=center width="100px"><font color="#000000"><nobr>RM
<?php echo $row->uprice;?> </nobr></font></td>
<table>
but i failed to show the no of products..
can you help to correct them??
i try using your way,still have problem like before..
i dont know how to declare using array..
$row->pid is retrieve from row of product in database..