Why wont this simple CSS work?

Red Squirrel

No Lifer
May 24, 2003
71,319
14,087
126
www.anyf.ca
I've been pulling my hair for over an hour, I just don't get it. it's not working.

I have a class called "listings" which applies to td and table, both have a border. It works more or less throughout the code.

Except one spot in the code that is a table inside a table. (Added a comment) for some reason it's completely being ignored. Whatever I put does not apply to the table. Sorry this is kinda big to go through, but it's simple enough.


This is my CSS template:

Code:
/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: verdana;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

/* end reset */


table.main
{
	width:500px;
	background:#000000;
	border-collapse: separate;
	border-spacing: 1px;
}

table.normal
{
	width:100%;
	border: 1px solid #000000;
}


td.title
{
	font-weight: bold;
	font-size:16px;
	background: #BBBBBB;
	padding: 5px;
	border: 1px solid #000000;	
}

td.normal
{
	background: #EEEEEE;
	padding: 5px;
	border: 1px solid #000000;	
}


td.tempdisp
{
	font-weight: bold;
	font-size:48px;
	background: #EEEEEE;
	padding: 10px;
	text-align:center;
	vertical-align:middle;
}


td.img
{	
	background: #EEEEEE;
	padding: 0px;
}


font.nav
{
	font-weight:bold;
	color:#000000;
}

a.nav, a.nav:visited
{
	font-weight:bold;
}

a.nav:hover
{
	font-weight:bold;
	color:#FF0000;
}






table.listing
{
	width:100%;
	border: 1px solid #000000;
}


td.listingtitle
{
	font-weight:bold;
	font: fixedsys,courier;
	border: 1px solid #000000;
	background: #F5F5F5;
	padding:7px;
}

td.listing
{
	font: fixedsys,courier;
	border: 1px solid #000000;
	background: #F5F5F5;
	padding:7px;	
}



table.form
{
	width:100%;
	background: #EEEEEE;
	border:1px solid #E6E6E6;
}

td.formright
{
	text-align:left;
	width:50%;
	background: #EEEEEE;	
	border:1px solid #E6E6E6;	
}

td.formleft
{
	text-align:right;
	width:50%;
	background: #EEEEEE;	
	border:1px solid #E6E6E6;	
}



input.formbutton
{
border: 1px solid #000000;
font-weight:bold;
background:#F6FFF6;
}

input.formbutton:hover
{
background:#FAFFFA;
}


input.formfield
{
border: 1px solid #000000;
width:100%;
font-weight:bold;
background:#F6FFF6;
}

select.formfield,option.formfield
{
border: 1px solid #000000;
font-weight:bold;
background:#F6FFF6;
}


input.formfieldnum
{
border: 1px solid #000000;
width:2em;
font-weight:bold;
background:#F6FFF6;
}


And this is my code:


Code:
<?php
$workid = NumOnly($_GET['pid']);
$workprogram = array();

if($workid>0)
{
	$res = MysqlQuery("SELECT pid,pname FROM program WHERE pid=".$workid." LIMIT 1;");	
	$workprogram = mysql_fetch_assoc($res);
	
	
	$workid=$workprogram['pid'];
}


//we are adding or saving an entry
if($_GET['act']=="edit" && $_POST['save']!="")
{
	$sname = FixSql($_POST['sname']);
	$shour = NumOnly($_POST['stime_hour']);
	$sminute = NumOnly($_POST['stime_minute']);
	
	$stemp_low = NumOnly($_POST['stemp_low']);
	$stemp_high = NumOnly($_POST['stemp_high']);
	
	$ssensor = NumOnly($_POST['ssensor']);
	$srelay = NumOnly($_POST['srelay']);

	
	if($workid>0 && $sname=="delete")
	{
		//delete:
		MysqlQuery("DELETE FROM program WHERE sid=".$workid." LIMIT 1;");
		
	}
	else if($workid>0)
	{
		//editing:
		
		MysqlQuery("UPDATE program set sname='".$sname."', shour='".$shour."', sminute='".$sminute."', stemp_low='".$stemp_low."', stemp_high='".$stemp_high."', ssensor='".$ssensor."', srelay='".$srelay."' WHERE sid='".$workid."' LIMIT 1;");
	
	}
	else
	{
		//adding:
	
		MysqlQuery("INSERT INTO program(sname,shour,sminute,stemp_low,stemp_high,ssensor,srelay)VALUES('".$sname."','".$shour."','".$sminute."','".$stemp_low."','".$stemp_high."','".$ssensor."','".$srelay."');");	
	
	}
	
}



?>

<table class="main">
<tr>
<td class="title">Programs</td>
</tr>
<tr><td class="main">


	<table class="listing">
	<tr>
	<td class="listingtitle">Name</td>
	</tr>

	<?php

	$ret = MysqlQuery("SELECT pid,pname FROM program order by pname ASC;");


	while($data = mysql_fetch_assoc($ret))
	{
		echo('
		<tr>
		<td class="listing"><a href="'.$linkprefix.'act=edit&amp;pid='.$data["pid"].'" class="normal">'.$data["pname"].'</a></td>
		</tr>
		');
	}


	?>

	</table>



</td></tr>
<tr>
<td class="title">

<?php

$data = array();

if($_GET['act']=="edit" && $workprogram['pid']!=0)
{
	echo("Editing Program: ".$data['sname']);	
	echo('</td></tr>');
}
else
{
	echo("Adding new program");	
	echo('</td></tr>');
}

?>
<tr><td class="normal">

	<form action="<?php echo($linkprefix);?>&act=edit&amp;id=<?php echo($workid);?>" method="POST">

	<table class="form">
	<tr>
	<td class="formleft">Name: </td>
	<td class="formright"><input type="text" name="sname" value="<?php echo($workprogram['pname']);?>" class="formfield"></td>
	</tr>	
	</table>
	
	
		
	<?php
	if($_GET['act']=="edit" && $workprogram['pid']!=0)
	{
		echo("<br><br>");
		$res = MysqlQuery("SELECT eid,eminute,ehour,etemp_low,etemp_high,esensor,erelay FROM programentry WHERE epid=".$workprogram['pid']." ORDER BY  ehour ASC,eminute ASC;");		
		
		
		while($data = mysql_fetch_assoc($res))
		{
		echo('
		<table class="listing">    <!--THIS CLASS IS BEING IGNORED FOR SOME -->REASON
		<tr>
		<td class="formleft">Time: </td>
		<td class="formright">'.GenTimeField($data['ehour'],$data['eminute'],"time_".$data['eid']).'</td>
		</tr>
		<tr>
		<td class="formleft">Temp Range: </td>
		<td class="formright"><input type="text" name="temp_low_'.$data['eid'].'" value="'.$data['etemp_low'].'" class="formfieldnum">-<input type="text" name="stemp_high_'.$data['eid'].'" value="'.$data['etemp_high'].'" class="formfieldnum"></td>
		</tr>
		<tr>
		<td class="formleft">Sensor: </td>
		<td class="formright">'.GenSensorField($data['esensor'],"sensor_".$data['eid']).'</td>
		</tr>
		<tr>
		<td class="formleft">Relay: </td>
		<td class="formright">'.GenRelayField($data['erelay'],"relay_".$data['eid']).'</td>
		</tr>		
		</table>		
		');		
		}
	}
	?>	
	
	
	
<br><center><input type="submit" name="save" value="Save" class="formbutton"></center>
</form>	

</td></tr>
</table>


Screenshot:

wunolistentocsscode.png


What is even more messed up is that it's working for the outside tables, but for some reason not that very specific inside one (there's actually two there). Any clue as to why?
 

Red Squirrel

No Lifer
May 24, 2003
71,319
14,087
126
www.anyf.ca
Ok I figured it out. First time using a reset template. Did not know about the border-collapse: separate; line that was required for any tables if I want the border to show up properly.