-1

嗨,我最近发现了如何在 php 中创建评论框!但是,当有人提交评论时,它会出现在之前的评论下方,我希望新评论出现在之前的评论之上,你能告诉我如何让评论框变小吗?

非常感谢,希望能帮到你:)

<?php
 mysql_connect("mysql10.000webhost.com","a5868186_test","honda33");
 mysql_select_db("a5868186_test");
 $name=$_POST['name'];
 $comment=$_POST['comment'];
  $submit=$_POST['submit'];

 $dbLink = mysql_connect("mysql10.000webhost.com", "a5868186_test", "honda33");
   mysql_query("SET character_set_client=utf8", $dbLink);
  mysql_query("SET character_set_connection=utf8", $dbLink);

if($submit)
 {
if($name&&$comment)
 {
 $insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES 
 ('$name','$comment') ");
 }
 else
 {
  echo "please fill out all fields";
   }
   }
  ?>
 <html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Comment box</title>
  </head>

  <body>
   <center>
   <form action="commentindex.php" method="POST">
  <table>
   <tr><td>Name: <br><input type="text" name="name"/></td></tr>
   <tr><td colspan="2">Comment: </td></tr>
   <tr><td colspan="5"><textarea name="comment" rows="10" cols="50"></textarea>   
   </td></tr>
     <tr><td colspan="2"><input type="submit" name="submit" value="Comment"></td></tr>
       </table>
      </form>
    <?php
       $dbLink = mysql_connect("mysql10.000webhost.com", "a5868186_test", "honda33");
      mysql_query("SET character_set_results=utf8", $dbLink);
     mb_language('uni');
      mb_internal_encoding('UTF-8');

     $getquery=mysql_query("SELECT * FROM commenttable ORDER BY id DESC");
      while($rows=mysql_fetch_assoc($getquery))
      {
    $id=$rows['id'];
   $name=$rows['name'];
    $comment=$rows['comment'];
     echo $name . '<br/>' . '<br/>' . $comment . '<br/>' . '<br/>' . '<hr size="1"/>'
   ;}
   ?>

   </body>
  </html>
4

1 回答 1

0

将日期字段添加到 MySQL 表并按日期字段排序。

于 2013-11-09T01:45:05.193 回答