Cheese Posted January 26, 2012 Share Posted January 26, 2012 I am having a problem with the formatting of my php, its most probably better if you look at the two screen shots I have attached below so you can see what I mean. Nicely formatted and displaying how it should. And this is one of the pages that is not displaying correctly. This is my code from the above page that has this problem, the reason why the page layout is in an echo is because that's the only way I could get text that was echoed to display within the page and with out lots of php errors. <?php // This is the page that displays users details and results $page_title = 'View my results'; include ('includes/var.php'); echo '<link rel="stylesheet" type="text/css" href="includes/layout.css" media="screen" />'; echo '<body>'; echo '<div id="wrapper">'; include('includes/header.html'); echo '<div id="content">'; echo '<h1>Registered Users</h1>'; require_once ('includes/mysqli_connect.php'); // Make the query: session_start(); $id=$_SESSION['user_id']; $q = "SELECT * from users where user_id='$id'"; $r = @mysqli_query ($dbc, $q); // Run the query. // Table header: echo '<table align="center" cellspacing="0" cellpadding="5" width="75%"> <tr> <td align="left"><b>Edit</b></td> <td align="left"><b>View</b></td> <td align="left"><b>Last Name</b></td> <td align="left"><b>First Name</b></td> </tr> '; $bg = '#eeeeee'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['user_id'] . '">Edit</a></td> <td align="left"><a href="view_student_results.php?id=' . $row['user_id'] . '">View</a></td> <td align="left">' . $row['last_name'] . '</td> <td align="left">' . $row['first_name'] . '</td> </tr> '; } // End of WHILE loop. echo '</table>'; mysqli_free_result ($r); mysqli_close($dbc); include ('includes/footer.html'); ?> I bet its something very simple that I have over looked but can someone please tell me where I am going wrong, starting to become a tad frustrated. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/ Share on other sites More sharing options...
AyKay47 Posted January 26, 2012 Share Posted January 26, 2012 this has to do with your CSS, post the CSS code Quote Link to comment https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/#findComment-1311275 Share on other sites More sharing options...
floridaflatlander Posted January 26, 2012 Share Posted January 26, 2012 Look at your html and see if any div or closing tag is missing. Run both through http://validator.w3.org/ Also is a div floated on the register page and causes the bottom of the page div come up? Quote Link to comment https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/#findComment-1311276 Share on other sites More sharing options...
spiderwell Posted January 27, 2012 Share Posted January 27, 2012 looks like an uncleared float to me Quote Link to comment https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/#findComment-1311709 Share on other sites More sharing options...
Cheese Posted January 29, 2012 Author Share Posted January 29, 2012 I solved the problem by clossing the DIV tag at the bottom of the page like so. <?php // This is the page that displays users details and results $page_title = 'View my results'; include ('includes/var.php'); echo '<link rel="stylesheet" type="text/css" href="includes/layout.css" media="screen" />'; echo '<body>'; echo '<div id="wrapper">'; include('includes/header.html'); echo '<div id="content">'; echo '<h1>Registered Users</h1>'; require_once ('includes/mysqli_connect.php'); // Make the query: session_start(); $id=$_SESSION['user_id']; $q = "SELECT * from users where user_id='$id'"; $r = @mysqli_query ($dbc, $q); // Run the query. // Table header: echo '<table align="center" cellspacing="0" cellpadding="5" width="75%"> <tr> <td align="left"><b>Edit</b></td> <td align="left"><b>View</b></td> <td align="left"><b>Last Name</b></td> <td align="left"><b>First Name</b></td> </tr> '; $bg = '#eeeeee'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> <td align="left"><a href="edit_user.php?id=' . $row['user_id'] . '">Edit</a></td> <td align="left"><a href="view_student_results.php?id=' . $row['user_id'] . '">View</a></td> <td align="left">' . $row['last_name'] . '</td> <td align="left">' . $row['first_name'] . '</td> </tr> '; } // End of WHILE loop. echo '</table> </div>'; // Closed this tag and the page worked fine. mysqli_free_result ($r); mysqli_close($dbc); include ('includes/footer.html'); ?> Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/#findComment-1312098 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.