php - 帖子重叠

标签 php html css

现在我不知道这是简单还是困难。如果只是CSS或PHP代码,我需要
但基本上我有发布系统,用户可以对帖子发表评论。在评论页面中,它显示原始帖子,并且一个用户离开了(评论)
我在那里一个,这很好,但是我又添加了一个,看起来像这样...
 

[1]:http://i.stack.imgur.com/2fIXd.jpg
如您所见,它完全不同!这是我的代码...
 

<?php           
mysql_connect("localhost", "root", "");      
mysql_select_db("test");           
echo "<a href='Untitled9.php'>Go Back...</a>"; 
?> 
<br/><br/> 

<div class="message">
<?php 
$sql = mysql_query("SELECT * FROM threads WHERE id = '". 
mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error());         
 while($r = mysql_fetch_array($sql))  {         
 $posted = date("jS M Y h:i",$r['posted']); echo "".$r['author']." &nbsp; $posted"; ?> 
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo "".$r['message'].""; ?>">
        Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<div class="message2"><?php echo "&nbsp;".$r['message'].""; ?></div> 
<?php  echo "Likes: ".$r['votes_up']."&nbsp;"; echo "Dislike: ".$r['votes_down']."";>        
</div>
<br/>
<hr width="725px">

<?php    
echo "<h3>Replies...</h3>"; ?>
<div class="message"><?php          
$sql = mysql_query("SELECT * FROM replies WHERE thread = '".
mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error());          
while($r = mysql_fetch_array($sql)) {          
$posted = date("jS M Y h:i",$r['posted']); echo "".$r['author']." &nbsp; $posted"; ?>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo "".$r['message'].""; ?>">
        Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>  
<div class="message2">
<?php echo "&nbsp;".$r['message']."" ; } ?> </div> 
</div>

<hr width="725px">

<form action="newreply.php" method="POST">      
Your Name: <input type="text" name="author">      
<input type="hidden" value="<?php echo $_GET['id']; ?>" name="thread"><br>      
Message:<br><textarea cols="60" rows="5" name="message"></textarea><br>      
<input type="submit" value="Post Reply">      
</form>


 代码在这里看起来很乱。我尝试进行编辑,但效果不佳。
 因此,基本上我想知道的是如何防止这种情况发生(重叠)?

编辑* CSS



.message {
width: 500px;
    color: black;
    background: white;
    padding:8px;
    border:1px solid white;
    margin:5px auto;
    -moz-border-radius:8px;
}   

.message2 {
background-color: grey;
}   


在我看来,似乎所有东西都在第二个php函数中发布,但是我对某些单独的帖子有一些代码几乎相同,并且这通常显示为我想要的数量。我只是想知道我是否需要添加/更改

最佳答案

错误(您的代码):

<?php echo "&nbsp;".$r['message']."" ; } ?> </div> 
</div>


正确:

<?php echo "&nbsp;".$r['message']."" ; ?> </div> 
</div>
<?php } ?>


您在while循环中打开了多个DIV,但仅关闭了两个。

关于php - 帖子重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6677345/

相关文章:

php - 查询字符串,从数据库或文件填充页面

html - 我的导航栏在 IE8 中看起来很糟糕。它实际上只是链接,根本没有样式发生

CSS min() 函数到 SASS

php - Symfony/学说 : How to make Doctrine working with Unix socket?

php - 如何在 zencart for PHP 中获取类别 ID?

php - 动态 JavaScript 表单,无 HTML 表单

jquery - 可编辑的 DIV HTML CSS

html - div 中的图像在图像下方有额外的空间

jquery - CSS 选择器和 jQuery 过滤器的区别?

javascript - LA24.org 是如何实现侧边菜单接近动画的?