Current location: Hot Scripts Forums » General Web Coding » CSS » layout problem with while loop


layout problem with while loop

Reply
  #1 (permalink)  
Old 02-20-08, 12:09 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
layout problem with while loop

Hey everyone,

I've got a layout problem when I have a while loop that will display a list of database entries.

The info is within a div but the output seems to be overlay'd on top of the div instead of inside the div.

The only thing that will I can do to make it look right is to add like 10 to 15 line breaks after the while loop. The number of line breaks needed will change depending on how many results are displayed so I don't want to just add line breaks.

Any ideas how to fix it? Check out the pictures and tell me what you think (the first screen shot it the bad one and the second is how it needs to look (I added line breaks).

Thank you. Let me know if you need any source code.

Sonny
Attached Images
File Type: jpg wrong.jpg (20.6 KB, 239 views)
File Type: jpg right.jpg (17.1 KB, 236 views)
Reply With Quote
  #2 (permalink)  
Old 02-20-08, 12:11 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
A link to the site where we can see the actual output would help. And the code you're using would be quite helpful too. All we can do this way is take wild guesses.
Reply With Quote
  #3 (permalink)  
Old 02-20-08, 12:19 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
unfortunately I'm coding locally on my machine. I'll post code.

header.php:

PHP Code:

<?php # Script 13.1 - header.html

// This page begins the HTML header for the site.

// Start output buffering.
ob_start();
// Initialize a session.
session_start();

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to Finding Mercury.com</title>
<meta name="robots" content="index, follow" />
<link rel="shortcut icon" href="favicon.ico" >
<link href="../css/fm.css" rel="stylesheet">
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="../swf/AC_RunActiveContent.js" language="javascript"></script>

</head>
<body>
<div id="contentbox">
  <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','height','200','src','../swf/admin','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../swf/admin' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="200">
<param name="movie" value="../swf/admin.swf">
    <param name="quality" value="high">
    <embed src="../swf/admin.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="200"></embed>
  </object></noscript>
  <div id="contentpad">
view_news.php

PHP Code:

<?php

require_once ('../includes/header.php');
include (
'../includes/config.inc.php');

require_once (
'../../../Connections/dbc.php'); // Connect to the db.

if (!isset($_SESSION['user_name'])) {
    echo 
'<p><font color="#FF0000">You must be logged in to view this page.</font></p><br /><br /><br /><br />
    <p><a href="login.php">login</a></p><br /><br />'
;
    include (
'../includes/footer.php');
    exit();
}else{

    
// Make the query.
$query "SELECT id, headline, news, DATE_FORMAT(date, '%m/%d/%Y') AS date FROM news ORDER BY DATE_FORMAT(date, '%Y %m %d') DESC";        
$result = @mysql_query ($query); // Run the query.
$num mysql_num_rows($result);

if (
$num 0) { // If it ran OK, display the records.

    // Table header.
    
echo '
    <table align="left" cellspacing="0" cellpadding="5">
    <tr>
        <td colspan="5" align="left"><a href="add_news.php">+ <u>add news</u></a></td>
    </tr>
    <tr>
        <td colspan="5" align="left"><a href="../quicknews.php"><u>view quicknews</u></a></td>
    </tr>
    <tr>
        <td align="left"><b>Edit</b></td>
        <td align="left"><b>Delete</b></td>
        <td align="left"><b>Headline</b></td>
    </tr>'
;
    
    
// Fetch and print all the records.
    
    
while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
        
        echo 
'
        <tr>
            <td align="left"><a href="edit_news.php?id=' 
$row['id'] . '"><u>edit</u></a></td>
            <td align="left"><a href="delete_news.php?id=' 
$row['id'] . '"><u>delete</u></a></td>
            <td align="left">' 
$row['headline'] . '</td>
        </tr>'
;
    }
echo 
'</table>';

?>
<br />
<?php
    mysql_free_result 
($result); // Free up the resources.    

} else { // If it did not run OK.
    
echo '<p><span class="reg">There are currently no news updates.</span></p>
            <p><a href="add_news.php">+ <u>add news</u></a></p>'
;
}

mysql_close(); // Close the database connection.

}


?>
footer.php
PHP Code:

</div>

</div>
<div id="footer"><p>&copy; <?php echo date('Y'); ?> Finding Mercury LLC | <a href="../sitecredits/">Site Credits</a> | <a href="../siteadmin/">Admin Site</a></p></div>
</body>
</html>
<?php // Flush the buffered output.
ob_flush();
?>
css:

Code:
body {
margin: 0 auto;
text-align: center;
color: #CCCCCC;
background:#151515 url(../images/body_bg.jpg) repeat-x scroll left top;
}


body,td {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #CCCCCC;
}

a {
color: #373737;
text-decoration: underline;
}

a:hover {
text-decoration: underline;
color: #373737;
}


a.small {
color: #373737;
text-decoration: underline;
font-size: 9px;
}

a.small:hover {
font-size: 9px;
text-decoration: underline;
color: #373737;
}

#contentbox {
width: 800px;
margin: 0 auto;
background-color: #000000;
border-left: 1px solid #373737;
border-right: 1px solid #373737;
border-bottom: 1px solid #373737;
}

#contentpad {
padding: 1px 7px 1px 7px;
background-color: #000000;
}

.divider {
margin: 2px auto 4px auto;
}

#footer {
height: 20px;
margin: 3px auto 0px auto;
font-size: 9px;
color: #CCCCCC;
}
Let me know if there is anything else you need.

Thank you again,

Sonny
Reply With Quote
  #4 (permalink)  
Old 02-21-08, 09:14 AM
Deansatch Deansatch is offline
Coding Addict
 
Join Date: Jul 2006
Location: Northumberland
Posts: 375
Thanks: 0
Thanked 0 Times in 0 Posts
have you tried setting overflow:auto; to the div in your css?
__________________
Aye!
Reply With Quote
  #5 (permalink)  
Old 02-21-08, 10:41 AM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Sweet!!!! That worked!

Thank you so much!

Sonny
Reply With Quote
  #6 (permalink)  
Old 02-21-08, 10:57 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
I'm moving your topic to the CSS section, since the problem wasn't really PHP related.

Even if it's solved now, others will find the solution easier here, when they're facing the same problem.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating Associative arrays with foreach divya PHP 13 11-21-07 01:12 PM
fluid website layout problem ste CSS 2 08-25-06 10:10 AM
A Language filter problem, and a problem with a for loop querying my database. . . Spreegem PHP 6 05-08-05 11:03 AM
Having a problem with a large while loop. . . Spreegem PHP 13 05-03-05 05:53 AM
SQL infinite loop problem with VB application Syed Visual Basic 2 05-07-04 10:19 AM


All times are GMT -5. The time now is 02:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.