mikebyrne Posted March 18, 2008 Share Posted March 18, 2008 My php output isnt alligned with my tables headings and its driving me mental!!! I've tried everything my code is <form> <!-- data title start --> <div id="containerBg2"> <div class="padTop2"><!-- --></div> <div class="clr"><!-- --></div> <div class="titleBox"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="33"> </td> <td width="87"><a href="#">Date</a></td> <td width="43" align="right"><a href="#">Orders</a></td> <td width="118" align="right"><a href="#">Revenue</a></td> <td width="569"> </td> </tr> </table> </div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- data title finish --> <!-- 1px space start --> <div id="containerBg1"> <div class="padTop1"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- 1px space finish --> <!-- data top start --> <div id="containerBg3"> <div class="padTop1"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- data top finish --> <!-- data content start --> <div id="containerBg4"> <?php include('adminconnect.php'); $sql = mysql_query("SELECT * FROM sales "); while( $row = mysql_fetch_array($sql) ) { ?> <tr align="left"> <td width="87" align="Left"><?php echo $row['Date'];?></td> <td width="43" align="Left"><?php echo $row['Total Orders'];?></td> <td width="118" align="Left"><?php echo $row['Revenue'];?></td> </tr> <?php } ?> </table> [code] I can mail printscreens if it helps as i can attach here anymore [/code] Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/ Share on other sites More sharing options...
lemmin Posted March 18, 2008 Share Posted March 18, 2008 You end your table toward the top and then you continue to use the <td> tags and add an extra </table> to te end that isn't doing anything. Without knowing what you are actually trying to make it look like, I would suggest you remove the first </table> so that your php outputs inside the table. Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494956 Share on other sites More sharing options...
mikebyrne Posted March 18, 2008 Author Share Posted March 18, 2008 No that still doesnt allign the figures under the headings but it does seperate them better Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494964 Share on other sites More sharing options...
lemmin Posted March 18, 2008 Share Posted March 18, 2008 You have 5 columns and you only add 3 things with PHP. Try putting this line below the <tr align=left> and above the date output: <td width="33"> </td> Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494967 Share on other sites More sharing options...
mikebyrne Posted March 18, 2008 Author Share Posted March 18, 2008 I now have the following code <form> <!-- data title start --> <div id="containerBg2"> <div class="padTop2"><!-- --></div> <div class="clr"><!-- --></div> <div class="titleBox"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="87"><a href="#">Date</a></td> <td width="43" align="left"><a href="#">Orders</a></td> <td width="118" align="left"><a href="#">Revenue</a></td </tr> </div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- data title finish --> <!-- 1px space start --> <div id="containerBg1"> <div class="padTop1"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- 1px space finish --> <!-- data top start --> <div id="containerBg3"> <div class="padTop1"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- data top finish --> <!-- data content start --> <div id="containerBg4"> <?php include('adminconnect.php'); $sql = mysql_query("SELECT * FROM sales "); while( $row = mysql_fetch_array($sql) ) { ?> <tr align="left"> <td width="87" align="Center"><?php echo $row['Date'];?></td> <td width="43" align="Center"><?php echo $row['Total Orders'];?></td> <td width="118" align="Center"><?php echo $row['Revenue'];?></td> </tr> <?php } ?> </table> <!-- data btm start --> <div id="containerBg3"> <div class="padTop1"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <!-- data btm finish --> <!-- btm start --> <div id="containerBg1"> <div class="padTop15"><!-- --></div> <div class="clr"><!-- --></div> </div> <div class="clr"><!-- --></div> <div id="container"> <div id="line"><!-- --></div> </div> <!-- btm finish --> </form> The allignment is getting a little better Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494971 Share on other sites More sharing options...
lemmin Posted March 18, 2008 Share Posted March 18, 2008 It is because you are making a bunch of random div's in the middle of the table fields. I don't have any idea what they are for, but since there is nothing in any of them, I would assume you can remove them. Also, since you moved the </table> tag, you are ending a div (that is started before the table) in the middle of the table. Assuming those divs are useless, try something like this: <form> <!-- data title start --> <div id="containerBg2"> <div class="padTop2"><!-- --></div> <div class="clr"><!-- --></div> <div class="titleBox"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="87"><a href="#">Date</a></td> <td width="43" align="left"><a href="#">Orders</a></td> <td width="118" align="left"><a href="#">Revenue</a></td </tr> <?php include('adminconnect.php'); $sql = mysql_query("SELECT * FROM sales "); while( $row = mysql_fetch_array($sql) ) { ?> <tr align="left"> <td width="87" align="Center"><?php echo $row['Date'];?></td> <td width="43" align="Center"><?php echo $row['Total Orders'];?></td> <td width="118" align="Center"><?php echo $row['Revenue'];?></td> </tr> <?php } ?> </table> </div> Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494979 Share on other sites More sharing options...
mikebyrne Posted March 18, 2008 Author Share Posted March 18, 2008 It seems like the headings need to be moved to the right Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494981 Share on other sites More sharing options...
lemmin Posted March 18, 2008 Share Posted March 18, 2008 You are aligning the header cells (two of them, at least) to the left and the output cells as centered. That is why it looks like they are farther to the left. Keep them all aligned the same. Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494987 Share on other sites More sharing options...
mikebyrne Posted March 18, 2008 Author Share Posted March 18, 2008 Thats fixed it. Cheers!! Although its knocked a line out either side of my container and i cant get it back Link to comment https://forums.phpfreaks.com/topic/96726-help-with-php-output-and-table/#findComment-494991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.