when I use Dreamweaver dynamic table option the tables print out like this:
<table border="1">
<tr>
<td width="110">ID PRODUCT</td>
<td width="97">PRODUCT</td>
<td width="149">STOCK</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_inventory['idprod']; ?></td>
<td><?php echo $row_inventory['prod']; ?></td>
<td><?php echo $row_inventory['cont']; ?></td>
</tr>
<?php } while ($row_inventory = mysql_fetch_assoc($inventory)); ?>
</table>
ID PRODUCT STOCK
| 1 | chair | 23 |
| 2 | table | 12 |
| 3 | pencil | 314 |
| 4 | pen | 523 |
| 5 | carpet | 23 |
But I want the table to print the data horizontally
example:
ID PRODUCT | 1 | 2 | 3 | 4 | 5 |
PRODUCT | chair | table | pencil | pen | carpet |
STOCK | 23 | 12 | 314 | 523 | 23 |
meaning:
ID PRODUCT is 1; the PRODUCT is a chair; there are 23 in stock ID PRODUCT is 2; the PRODUCT is a table; there are 12 in stock ID PRODUCT is 3; the PRODUCT is a pencil; there are 314 in stock and so on...
For there is no data in my database, so I use an array instead. just for an example, i used the following
$arr = array(
array('ID' => '1',
'PRODUCT' => 'chair',
'STOCK' => '23'),
array('ID' => '2',
'PRODUCT' => 'table',
'STOCK' => '12'),
);
<table border="1">
<tr>
<td width="110">ID PRODUCT</td>
<?php foreach ($arr as $key => $value)
{ ?>
<td><?php echo $value['ID']; ?></td>
<?php } ?>
</tr>
<tr>
<td width="97">PRODUCT</td>
<?php foreach ($arr as $key => $value)
{ ?>
<td><?php echo $value['PRODUCT']; ?></td>
<?php } ?>
</tr>
<tr>
<td width="149">STOCK</td>
<?php foreach ($arr as $key => $value)
{ ?>
<td><?php echo $value['STOCK']; ?></td>
<?php } ?>
</tr>