Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

CSS refuses to obey my wishes

I am trying to make a very simple web page to output a work schedule from a csv file. it can output the values but it does not fromat very nicely.

i want to have the data in a centered box, but i print it, with all the cells set to absolute positioning with position determined by php, and they dont go in the box, and the box goes to its minimum size. its really annoying

this is my code

you can see the page at alex.jowigo.com/schedule.php

<html>
<head>
<title> Uxbridge Library Schedule </title>
</head>
<style type="text/css">
#main {
width:1004px;
margin-right:auto;
margin-left:auto;
margin-top:10px;
padding:0px;
text-align:left;
border:1px solid #000;

}

#head
{
border-width:thin;
width:100px;
border-style:solid;
border-top-width:0px;
position:absolute;
text-align:center;
}

#datum
{
border-width:thin;

width:100px;
border-style:solid;
border-top-width:0px;
border-bottom-width:0px;
position:absolute;
text-align:center;
}

</style>
<body>

<?php
$filepath = "hours.csv";
$f = fopen($filepath,"r");
for($i=1 ; $i <= 54 ; $i++)
{
$inp=fgets($f);
for($x=1;$x<=7;$x++)
{
$tmp = stristr($inp,",");
$res[$i][$x] = substr($inp,0,strlen($inp)-strlen($tmp));
$inp=substr($tmp,1,strlen($tmp));
}
}

for($x=1;$x<8;$x++)
{
for($i=1;$i<3;$i++)
{
$bordertype[$i][$x]="head";
}
for($i=3;$i<27;$i++)
{
$bordertype[$i][$x]="datum";
}
for($i=27;$i<30;$i++)
{
$bordertype[$i][$x] ="head";
}
for($i=30;$i<55;$i++)
{
$bordertype[$i][$x]="datum";
}
}


$rowheight = 20;
<div id='main'>
for($i=1;$i<55;$i++)
{
for($x=1;$x<8;$x++)
{
$result = $result . "<div id='" . $bordertype[$i][$x] . "' style='left: " . 100 * ($x - 1) . "px; top: " . $i * $rowheight . "px ' > " . $res[$i][$x] . "</div>";
}
</div>
}

echo $result;



?>

</body>
</html>
[2503 byte] By [notquitehere188] at [2007-11-11 10:27:10]
# 1 Re: CSS refuses to obey my wishes
You can't use margin-right:auto, and margin-left :auto. It's margin:auto; to center
JPnyc at 2007-11-11 23:34:23 >
# 2 Re: CSS refuses to obey my wishes
But, i want to have different margins at top and bottom, wouldnt that be how i do it.

also, it still fails to work after that change
notquitehere188 at 2007-11-11 23:35:29 >