Hi i have problems centering the two tables below in the webpage, as i want the 2 tables to be near each other, i manage to do that but i cant seem to be able to get them in the center , the file is attached just look the page in a normal webpage view thanks
try the following. change the width of div id "my_right" and "my_right" <? session_start(); ?> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="style.css" /> <style type="text/css"> <!-- #leftCol { float: left; width: 120px; /* Or whatever you want */ } #rightCol { float: left; width: 600px; /* height: 500px;*/ overflow: auto; /*position:absolute; left: 421px;*/ } #rightCol table { width: 1200px; overflow: auto; } --> </style> </head> <?php include ("include/function.php"); include ("include/interface.php"); ?> <body> <center> <?php displayLogo(); $con = connectToMysql(); $subjectcode=$_SESSION['subjectcode']; if (isset($_GET['scheduleid'])) { $scheduleid = $_GET['scheduleid']; } $res = @mysql_query("select day,time,room from tblschedule where scheduleid='$scheduleid'",$con) or die("Error select tblschedule: ".mysql_error()); $row = mysql_fetch_object($res); $day = $row->day; $time = "$row->time"; $room = $row->room; ?> <div align="left" style="width:90%"> <a href="Main Page.php"> Home</a> <img src="pictures/arrow.png"/> <a href="Subject Page.php">Subject Page</a> <img src="pictures/arrow.png"/> <a href="Subject Schedule Page.php?subjectcode=<?=$subjectcode?>"> <?=$subjectcode?> </a> <img src="pictures/arrow.png"/> <a href="List of student within a schedule.php?scheduleid=<?=$scheduleid?>&subjectcode<?=$subjectcode?>">Student List</a> <img src="pictures/arrow.png"/> <a href="#">Grades</a></div> <table width="90%" border="1" bordercolor="#000000"> <tr bgcolor="#336699"> <td width="135"> <div align="center"><font color="#FFFFFF">Studno</font></div> </td> <td width="156"> <div align="center"><font color="#FFFFFF">Name</font></div> </td> <td width="92"> <div align="center"><font color="#FFFFFF">Prelims</font></div> </td> <td width="108"> <div align="center"><font color="#FFFFFF">Midterms</font></div> </td> <td width="87"> <div align="center"><font color="#FFFFFF">Finals</font></div> </td> <td width="82"> <div align="center"><font color="#FFFFFF">Total</font></div> </td> </tr> <?php $result = mysql_query ("select studno,firstname,middlename,lastname from tblclass inner join tblstudent using (studno) where scheduleid = '$scheduleid'",$con); if (mysql_num_rows($result)>0) { while ($row = mysql_fetch_object($result)) { ?> <tr> <td> <div align="center"><?php echo "$row->studno"; ?></div> </td> <td> <div align="center"><?php echo ucwords("$row->firstname $row->middlename $row->lastname"); ?></div> </td> <td> <div align="center"> <?php $score = calculatePart ('tblprelimssettings',$part = 1,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $score = calculatePart ('tblmidtermssettings',$part = 2,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $score = calculatePart ('tblfinalssettings',$part = 3,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $grade = getSubjectGradeInTblgrade ($scheduleid,$row->studno,$con); if ($grade) { echo $grade; } else { echo "Not Finished"; } ?> </div> </td> </tr> <?php } } else { ?> <tr> <td colspan="6">There are no students in this class.</td> </tr> <?php } ?> </table> <p> </p> </center> <!-- my edit --> <div style="float:left; width:33%; height:auto;" id="my_left"> <table border="1" bordercolor="#000000" align="right"> <tr bgcolor="#336699"> <td> <div align="center"><font color="#FFFFFF">Studno</font></div> </td> <td> <div align="center"><font color="#FFFFFF">Name</font></div> </td> </tr> <?php $result = mysql_query ("select studno,firstname,middlename,lastname from tblclass inner join tblstudent using (studno) where scheduleid = '$scheduleid'",$con); if (mysql_num_rows($result)>0) { while ($row = mysql_fetch_object($result)) { ?> <tr> <td align="center"> <?php echo "$row->studno"; ?></td> <td align="center"> <?php echo ucwords("$row->firstname $row->middlename $row->lastname"); ?></td> </tr> <?php } } else { ?> <tr> <td colspan="2">There are no students in this class.</td> </tr> <?php } ?> </table> </div> <div style="float:left; width:57%; height:auto;" id="my_right"> <div id="rightCol"> <table border="1" bordercolor="#000000"> <tr bgcolor="#336699"> <td width="92"> <div align="center"><font color="#FFFFFF">Prelims</font></div> </td> <td width="108"> <div align="center"><font color="#FFFFFF">Midterms</font></div> </td> <td width="87"> <div align="center"><font color="#FFFFFF">Finals</font></div> </td> <td width="82"> <div align="center"><font color="#FFFFFF">Total</font></div> </td> </tr> <?php $result = mysql_query ("select studno,firstname,middlename,lastname from tblclass inner join tblstudent using (studno) where scheduleid = '$scheduleid'",$con); if (mysql_num_rows($result)>0) { while ($row = mysql_fetch_object($result)) { ?> <tr> <td> <div align="center"> <?php $score = calculatePart ('tblprelimssettings',$part = 1,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $score = calculatePart ('tblmidtermssettings',$part = 2,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $score = calculatePart ('tblfinalssettings',$part = 3,$row->studno,$scheduleid,$con); /* Because calculatePart also returns N/A we must check it. */ if (is_numeric($score)) { echo sprintf("%3.2f",$score); } else { echo $score; } ?> </div> </td> <td> <div align="center"> <?php $grade = getSubjectGradeInTblgrade ($scheduleid,$row->studno,$con); if ($grade) { echo $grade; } else { echo "Not Finished"; } ?> </div> </td> </tr> <?php } } else { ?> <tr> <td colspan="4">There are no students in this class.</td> </tr> <?php } ?> </table> </div> </div> <!-- --> </body> </html> HTML:
It is very basic knowledge to make the table nested to each other and make them centered . You need more hard work, guy .
Good lord, why are people still using tables for layout? Isn't that sort of like hammering nails with a rock?
I can't see th file, because Firefox doesn't realise it's just a text file and cannot open it, however the name suggests tabular data. However the tables I see in softnmore's copy sure do show a nasty table. jigen, it would be a good idea to learn more about tables. Adding font and center tags to tables destroys their rigid beauty. Specifically, learn how to use CSS in tables to set things like font colour. No need to add extra divs inside td's, they can have stuff inside them alone just fine. Look up things like table headers, and the scope attribute. And especially, the caption or summary. So we know just by looking what that table's about.
Please do not post your php script for a css or html question. We need to see the source the browser gets. Open your browser, view source and upload that to the thread. Better would be to post a link to the page so we could see it in action. cheers, gary