Page 1 of 1

Php tables with css

Posted: Tue Jul 13, 2010 9:51 pm
by MHardeman25
Damn, I really hate to be a burden. This is the second time in about 4 hours I've posted with something that is probably a simple error.
Anywho, I'm trying to apply css to a table that I'm printing out with php. The code looks kind of like this.

Code: Select all

<div id='info'>
<link rel='stylesheet' href='content-layout.css'>
	<table class='infoTable'>
	<?php
		foreach($userInfo as $field => $value){
			echo '<tr>';
			echo "<td class='elements'>".$field."</td><td>".$value."</td>";
			echo '</tr>';
		}
	?>
	</table>
</div>
the css is in a seperate file, the one I referenced with the link.
it looks like this

Code: Select all

body
{
	margin: 0;
	color: #666666;
	background-color: #000000;
	font-family: serif, verdana;
}

#info.infoTable
{	
	border: 1px solid #FFFFFF;
	background-color: #666666;
	padding: 5%;
}
basically, the css doesn't work on the table, I've tried everything. Changing the classes to id's and back
applying the css to different parts. Changing where the table tag is in the html/php. I got nothing.

Re: Php tables with css

Posted: Tue Jul 13, 2010 10:09 pm
by jraede
Your CSS isn't doing what you want it to do - I'm not sure if "#info.infoTable" is even valid syntax, but if it is, then it's selecting anything with id="info" and class="infoTable". Put a space in between to select any element with class "infoTable" within an element with id "info".

Re: Php tables with css

Posted: Tue Jul 13, 2010 10:10 pm
by MHardeman25
sorry, it should be just a .infoTable, but that doesn't work either.

Re: Php tables with css

Posted: Tue Jul 13, 2010 10:33 pm
by jraede
What does your CSS file look like now?

Re: Php tables with css

Posted: Tue Jul 13, 2010 10:36 pm
by MHardeman25

Code: Select all

body
{
	margin: 0;
	color: #666666;
	background-color: #000000;
	font-family: serif, verdana;
}

.infoTable
{	
	border: 1px solid #FFFFFF;
	background-color: #666666;
	padding: 5%;
}

Re: Php tables with css

Posted: Tue Jul 13, 2010 10:45 pm
by MHardeman25
even if I do this, I get nothing. The css is as simple as it gets, I don't see the problem.

Code: Select all

body
{
	margin: 0;
	color: #666666;
	background-color: #000000;
	font-family: serif, verdana;
}

#info
{	
	border: 1px solid #FFFFFF;
	background-color: #666666;
	padding: 5%;
}

.infoTable
{	
	border: 1px solid #FFFFFF;
	background-color: #666666;
	padding: 5%;
}

.elements
{	
	border: 1px solid #FFFFFF;
	background-color: #666666;
	padding: 5%;
}
all i'm really trying to do is put boarders and colors so i can see what i'm doing.

Re: Php tables with css

Posted: Tue Jul 13, 2010 11:50 pm
by jraede
From my experience it's easier to style TR than TD (in fact, I've noticed that TD doesn't work on many occasions). But as far as the table as a whole, it's hard for me to help you if I can't see it. Is the white border showing up at all?

Re: Php tables with css

Posted: Tue Jul 13, 2010 11:50 pm
by MHardeman25
Hold on, for some crazy reason, it just randomly decided to work.

Re: Php tables with css

Posted: Tue Jul 13, 2010 11:51 pm
by MHardeman25
I haven't changed anything. I just refreshed the page like 10 times and it finally worked.

Re: Php tables with css

Posted: Tue Jul 13, 2010 11:51 pm
by jraede
Your browser probably cached the old CSS file. Glad it's working now.