CSS or HTML Data tables?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bgareth
Forum Newbie
Posts: 2
Joined: Thu Oct 28, 2010 7:40 am
Location: Manchester

CSS or HTML Data tables?

Post 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.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: CSS or HTML Data tables?

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply