View Single Post
Old 03-21-2010, 12:17 AM  
harvey
Confirmed User
 
harvey's Avatar
 
Industry Role:
Join Date: Jul 2001
Location: 127.0.0.1
Posts: 9,266
Quote:
Originally Posted by Jakez View Post
Let's say you want to GENERATE the following type of structure from 12 rows of MySQL data using PHP and a horizontal columns number that can be changed by the webmaster (set to 4 here):



CSS
1: As far as I know, you'd need to know the exact px width of the 'container' and then divide that by the amount of box's (columns) that are set, as well as subtracting paddings, borders, etc., which sounds really messy IMO. Uh oh, what if the person set it to 5 instead of 4? Do a bunch of math in PHP to figure out the new correct width? But then how do you set the 'container' width in your .css file to match the new width?

2: Don't use a 'container' and just spit out 12 <div>'s one after another, use PHP to put a <br> after every 4 columns, or 5, whatever is set? But you have to eventually place this into some kind of 'container' in your layout which is going to have a set width. Fuck.

Tables
1: First lay down <table><tr>, then loop through the 12 rows of MySQL data placing </tr><tr> after every 4 or 5, then put </tr></table> after all that is done. Except if you check the source of the page you will have an empty <tr></tr> at the end.

And then both of these become a LOT more confusing when you try to implement a template system. How do you know whether to use <br> or </tr><tr> since you don't know whether the persons page is created with CSS or Tables?
you're giving the answer yourself. Even though tables are meant for tabular data, if you need flexibility, CSS is the way to go. It's not a coincidence any serious developer is using CSS for almost anything. Even tabular data. Just modify 1 number or variable and you can have more columns. Or rows. Or whatever.

Plus, something many people seems to ignore is that YOU CAN HAVE TABLES WITH CSS. Just use display:table (or display:table-cell, or table-row, or table-column or whatever). Thus, you can have tables and all the power of CSS at the same time. Or you can use table-layout property (although in IE8 you'll need to set auto or fixed, not inherit, which I never use, so what do I care)

Seriously, there's not even an argument here
__________________
This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth
harvey is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote