Page 1 of 1

CSS or HTML Data tables?

Posted: Mon Dec 06, 2010 11:06 am
by bgareth
Hi there,

I have read a long guide online about working with PHP but now I need to know whether to use a CSS table or a HTML table for information stored in a MySQL table.

Information includes Email addresses, names, telephone numbers etc and I want a visual table on the page. If I design in HTML does it mean that I lose the ability to make the table look nice by varying widths of borders around cells, colours and fonts etc. If CSS is the way forward, I really struggle with it so I would be greatful if you could provide links to really easy and straight forward tutorials (where things are spelt out rather than people being assumed to have a level of knowledge) in order to design the tables. Also how do you do the code for the cells and where do you put it (for example to list all the records within a database in a list in a visual (gridded) table and how can I specify only to display records with columns containing certain values - for example only postcodes with "cv32" in them?

Thanks for your help,

Ben.

Re: CSS or HTML Data tables?

Posted: Mon Dec 06, 2010 12:09 pm
by social_experiment
You'd probably use both. HTML is the 'building blocks' and CSS would be the paint in this analogy.
bgareth wrote:If I design in HTML does it mean that I lose the ability to make the table look nice by varying widths of borders around cells, colours and fonts etc.
Not at all (see above analogy). Here's a short example of what your code might be like

Code: Select all

<table id="information_table">
<tr><th>Name</th><th>Email Address</th></tr>
<tr><td>Billy</td><td>billy@home.com</td></tr>
</table>
With CSS you can style as follows

Code: Select all

table#information_table {
 // css syntax here
}
tr {
 // css syntax here
}
td {
 // css syntax here
}
You can probably find loads of CSS tutorials using google but 2 book that's are worth checking out is The art and science of CSS & Pro CSS techniques. The last one might sound advanced but it covered loads of important stuff.
bgareth wrote:Also how do you do the code for the cells and where do you put it (for example to list all the records within a database in a list in a visual (gridded) table and how can I specify only to display records with columns containing certain values - for example only postcodes with "cv32" in them?
Paste some of your code that you have created.