1

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...

Edgar Mtz
  • 63
  • 1
  • 1
  • 5

1 Answers1

0

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>

iatboy
  • 1,295
  • 1
  • 12
  • 19
  • I used only two sets of data just for example – iatboy Jul 31 '14 at 03:28
  • I want to know if dreamweaver can do this. – Edgar Mtz Jul 31 '14 at 03:36
  • sorry, I just do not use dreamweaver. however my answer you can take into consideration – iatboy Jul 31 '14 at 03:44
  • I am still trying with dreamweaver. I tried the way you commented a few days back but the problem is that I have two tables. I want all the data within one table and to do that I would need Dreamweaver's assistant which has the ability to do joins and other sql sentences easily. Once I get the table how I want it with Dreamweaver's assistant I should be able to get the rest down. – Edgar Mtz Aug 01 '14 at 06:54