亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php開發(fā)留言板之查看留言


創(chuàng)建文件list.php

<!DOCTYPE html>
 <html lang="utf-8">
 <head>
    <?php
 include ("conn.php");
 ?> 
  <link href="css.css" rel="stylesheet" type="text/css">
 </head>
 
 
 <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef" >
     <?php
     $sql="select * from message order by id desc";
     $query=mysql_query($sql);
     while($row=mysql_fetch_array($query)){  ?>
 
         <tr bgcolor="#eff3ff">
             <td>標(biāo)題: <?php echo $row['title'];?> <font color="red">用戶: <?php echo $row['user'];?> </td>
         </tr>
         <tr bgColor="#ffffff">
             <td>發(fā)表內(nèi)容:<?php echo $row['content'];?></td>
         </tr>
         <tr bgColor="#ffffff">
             <td><div align="right">時(shí)間:<?php echo $row['lastdate'];?></td>
         </tr>
     <?php } ?>
     <tr bgcolor="#f0fff0">
         <td><div align="right"><a href="add.html">返回留言</a> </td>
     </tr>
 </table>
 </html>

引入css樣式文件和conn數(shù)據(jù)庫文件

<?php
    $sql="select * from message order by id desc";
    $query=mysql_query($sql);
    while($row=mysql_fetch_array($query)){ 
    } ?>

連接message數(shù)據(jù)庫進(jìn)行倒敘排序

mysql_query進(jìn)行查詢

mysql_fetch_array()-獲取和顯示數(shù)據(jù)格式
然后把所需的數(shù)據(jù)分別寫出來

寫到這留言板基本已經(jīng)成型了,后面可以給留言板添加刪除功能,讓其更為完善。


本章重點(diǎn):

  1. 在html語句中插入php語句,HTML和PHP的混編。

  2. 使用倒敘的方式顯示數(shù)據(jù),最新的放在最前面,更能符合人們使用的習(xí)慣。

  3. mysql_query進(jìn)行查詢和mysql_fetch_array()-獲取和顯示數(shù)據(jù)格式這兩個(gè)方法的使用。

繼續(xù)學(xué)習(xí)
||
<!DOCTYPE html> <html lang="utf-8"> <head> <?php include ("conn.php"); ?> <link href="css.css" rel="stylesheet" type="text/css"> </head> <table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef" > <?php $sql="select * from message order by id desc"; $query=mysql_query($sql); while($row=mysql_fetch_array($query)){ ?> <tr bgcolor="#eff3ff"> <td>標(biāo)題: <?php echo $row['title'];?> <font color="red">用戶: <?php echo $row['user'];?> </td> </tr> <tr bgColor="#ffffff"> <td>發(fā)表內(nèi)容:<?php echo $row['content'];?></td> </tr> <tr bgColor="#ffffff"> <td><div align="right">時(shí)間:<?php echo $row['lastdate'];?></td> </tr> <?php } ?> <tr bgcolor="#f0fff0"> <td><div align="right">< a href=" ">返回留言</ a> </td> </tr> </table> </html>
提交重置代碼