Jump to content

Recommended Posts

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.

1b87fb90.jpg

 

And this is one of the pages that is not displaying correctly.

19a62a35.jpg

 

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.

Link to comment
https://forums.phpfreaks.com/topic/255796-pages-not-displaying-correctly/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.