Skip to content
Advertisement

How to make all PHP echo values go into a HTML Table

How do I fix this issue, you see in the picture below, my code creates a table successfully and echos the first item correctly, but if any other item is added to the cart, it gets displayed below the table, outside the border, not in a row.

Desired Result: For ‘Sara Lee Muffin’ and the quantity, and price (example) to be inside the table in it’s own row and remove button. (Basically set out the exact same way a the Toasted Sandwhich, but below it)

My code is below the image.

enter image description here

JavaScript

Advertisement

Answer

You have a closing </table> inside your foreach loop, so every item in the array prints out a </table> tag.

You should add another check for the shopping cart after the loop, and if it exists, print the closing </table> tag.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement