Jump to content

populate html table with array


inestine

Recommended Posts

I have a table that allows users to add rows, depending on how much data they need to insert. upon submit I'd like to populate another table for review. Now I can generate the data, but I'm having trouble putting the array into a table. Here is the output from the initial page:

 

Array
(
    [quantity] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [description] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [unit_cost] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [shipping] => 4
    [tax] => 5
    [review_po] => Review
)

 

I need it to look like this:

Quantity | Description | Unit Cost

1            | 1                | 1

2            | 2                | 2

3            | 3                | 3

                Tax              | 4

                Ship            | 5

 

I think it's a foreach statement, but I'm not having any luck..

 

If someone could point me in the right direction???

Link to comment
https://forums.phpfreaks.com/topic/248125-populate-html-table-with-array/
Share on other sites

Question: Will the table example you showed always be of those dimensions (IE the quantity and description inner arrays will always have 3 elements) or could the table look different depending on the array (who's size and format may be different every time the script runs)?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.