php我有一个评论系统移动评论更接近

时间:2012-08-10 09:16:15

标签: php html comments echo move

我有一个网站,您可以在其中显示您的推特链接,人们可以关注您,我不希望这些帖子靠近在一起,因为您可以看到它们相距太远这就是网站http://twitterdistrict.comuf.com/index.php

评论代码是这个

<?php
require('connect.php');
$query=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($query))
{
     $id=$rows['id'];
     $dname=$rows['name'];
     $dcomment=$rows['comment'];

     echo '<div id="username_word"><font color="red">username:</font></div>' ."<a href='$dname' id = 'name' style='color: #77cde6' STYLE='TEXT-DECORATION: NONE'>$dname</a>"."<div id ='dash'><font color='red'> - </font> </div>"."<div id='comment'>$dcomment</div>" 
  ."<div id='followbtn'><a href='$dname'><img src='http://i45.tinypic.com/2yltzkg.png' width ='30px' height ='30px' border='0' alt='follow'></div></a>" ;    

     }
?>

1 个答案:

答案 0 :(得分:0)

我建议代码:

<?php
require('connect.php');
$query=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($query))
{
     $id=$rows['id'];
     $dname=$rows['name'];
     $dcomment=$rows['comment'];
?>
<div id="username_word"><font color="red">username:</font></div><a href="<?php echo $dname; ?>" id="name" style="color: #77cde6" STYLE="TEXT-DECORATION: NONE"><?php echo $dname; ?></a><div id="dash"><font color="red"> - </font> </div><div id="comment"><?php echo $dcomment; ?></div><div id="followbtn"><a href="<?php echo $dname; ?>"><img src="http://i45.tinypic.com/2yltzkg.png" width ="30px" height ="30px" border="0" alt="follow"></div></a>
<?php
 }
?>

我用简单的HTML取代了echo。通过在HTML代码中使用echo将值插入到HTML中。