奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

php語言

PHP簡單留言本功能的實現(xiàn)代碼

時間:2025-03-08 10:00:25 php語言 我要投稿
  • 相關(guān)推薦

PHP簡單留言本功能的實現(xiàn)代碼

  這篇文章主要為大家詳細介紹了PHP簡單留言本功能的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下,想了解更多相關(guān)信息,請持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!

PHP簡單留言本功能的實現(xiàn)代碼

  index.php:

  <?php

  error_reporting(0); //關(guān)閉NOTICE提示

  require_once "conn.php";

  $pagesize=5;   //每頁顯示5條數(shù)據(jù)

  $sql="select count(*) from guestlist "; //選擇數(shù)據(jù)庫,計算符合條件的行數(shù)并返回行數(shù)

  $result= mysql_query($sql);  //執(zhí)行,如果成功則返回結(jié)果集(從數(shù)據(jù)庫中找到所有的數(shù)據(jù),返回條數(shù))

  $row = mysql_fetch_row($result);  //獲得數(shù)組 Array[0]="數(shù)據(jù)庫里的總條數(shù)"

  $infoCount =$row[0]; //獲得總條數(shù):取得數(shù)組中的值$row[0]="數(shù)據(jù)庫里的總條數(shù)"

  $pageCount = ceil($infoCount/$pagesize); //獲取總頁數(shù)(總個數(shù)/每頁的個數(shù)5)

  $currpage=empty ($_GET["page"])?1:$_GET["page"]; //如果當前頁為空 則定義page=1即$currpage=1反之亦然

  if($currpage>$pageCount)  //如果輸入的頁數(shù)超過總頁數(shù)則默認跳轉(zhuǎn)到最后一頁

  {

  $currpage=$pageCount;

  }

  ?>

  <!DOCTYPE html>

  <html>

  <head>

  <meta charset="utf-8" />

  <title></title>

  <!--此處添加了bootstrip樣式-->

  <link href="../dist/css/bootstrap.min.css" rel="external nofollow" type="text/css" rel="stylesheet" />

  <link href="css/index.css" rel="external nofollow" type="text/css" rel="stylesheet" />

  <script>

  function test(){

  var sum;

  if(document.frm.title.value==''){

  alert('請?zhí)顚憳祟}');

  return false;

  }else{

  sum =document.frm.title.value.length;

  if(sum<5 || sum>20){

  alert('標題長度 5-20個字符');

  return false;

  }

  }

  if(document.frm.username.value==''){

  alert('請?zhí)顚懹脩艟W(wǎng)名');

  return false;

  }

  if(document.frm.content.value==''){

  alert("請?zhí)顚憙?nèi)容");

  return false;

  }

  return true;

  }

  </script>

  </head>

  <body>

  <p class="content">

  <h5 style="color: red;"><?php echo $infoCount;?>條留言</h5><br/>

  <ul class="bt">

  <li>留言標題</li>

  <li>用戶網(wǎng)名</li>

  <li>時間</li>

  </ul>

  <?php               //從當前頁開始 向下取出5個

  $re= mysql_query("select * from guestlist order by id desc limit ".($currpage-1)*$pagesize.",".$pagesize);

  while($row= mysql_fetch_assoc($re)) //得到一行數(shù)據(jù)的數(shù)組,再執(zhí)行則得到再下一行,如果得到是最后一行,那么再執(zhí)行則返回false

  {

  ?>

  <ul class="nr">

  <li><?php echo $row["title"];?></li>

  <li><?php echo $row["username"];?></li>

  <li><?php echo $row["addtime"];?></li>

  </ul>

  <p class="lynr">

  <p><strong>留言內(nèi)容:</strong></p><span><?php echo $row["content"];?></span>

  </p>

  <?php

  }

  ?>

  <hr style="width:800px"/>

  <ul class="pagination">

  <!--上一頁-->

  <?php

  for($i=1;$i<=$pageCount;$i++)

  {

  if($i==$currpage)

  {

  echo "<li><a href=?page=".($i-1).">?</a></li>";

  }

  }

  ?>

  <!--數(shù)字頁-->

  <?php

  for($i=1;$i<=$pageCount;$i++)

  {

  if($i==$currpage)

  {

  echo "<li ><a style='background-color:#EEEEEE'>$i</a></li>";

  }else{

  echo "<li><a href='?page=$i'>$i</a></li>";}

  }

  ?>

  <!--下一頁-->

  <?php

  for($i=1;$i<$pageCount;$i++)

  {

  if($i==$currpage)

  {

  echo "<li><a href=?page=".($i+1).">?</a></li>";

  }

  }

  ?>

  </ul>

  <br/>

  <ul>

  </ul>

  <hr/>

  <strong style="color:red">發(fā)表留言</strong>

  <form action="result.php" method="post" name="frm" onsubmit="return test()">

  <table cellpadding="0" cellspacing="0" >

  <tr>

  <td >留言標題:</td>

  <td><input type="text" name="title" autocomplete="off"/></td>

  </tr>

  <tr>

  <td>網(wǎng)名:</td>

  <td><input type="text" name="username" autocomplete="off"/></td>

  </tr>

  <tr>

  <td>留言內(nèi)容:</td>

  <td><textarea name="content" cols="42" rows="5" autocomplete="off"/></textarea></td>

  </tr>

  <tr>

  <td></td>

  <td><input class="btn" type="submit" name="submit" value="提交"/></td>

  </tr>

  </table>

  </form>

  </p>

  </body>

  </html>

  conn.php

  <?php

  $link = mysql_connect("localhost","root"," ");

  mysql_select_db("guestbook");

  mysql_query("set names utf-8");

  if(!$link){

  die("Connection failed: " . mysqli_connect_error());

  }

  //echo "鏈接成功";

  ?>

  result.php

  <?php

  error_reporting(0);                          //關(guān)閉NOTICE提示

  require_once "conn.php";

  $title = $_REQUEST['title'];

  $username = $_REQUEST['username'];

  $content = $_REQUEST['content'];

  $content = str_replace("\n","<br>",str_replace(" "," ",$content)); //顯示'空格'和'回車'

  $week = '星期'.mb_substr( "日一二三四五六",date("w"),1,"utf-8" );

  $isok =mysql_query("insert into guestlist(title,username,content,addtime)values('$title','$username','$content','".date("Y-m-d H:i:s")." $week ')");

  if($isok)

  {

  echo "<script>

  alert('提交成功');

  location.href='index.php';

  </script>";

  }else {

  echo "<script>

  alert('提交失敗');

  location.href='index.php';

  </script>";

  }

  ?>

  css/index.css:

  body{margin:0;padding:0;}

  ul,li{list-style: none;margin:0;padding:0;}

  a{text-decoration: none;}

  .content{

  width:800px;

  margin:0 auto;

  }

  .bt{

  width:799px;

  height:20px;

  text-align: center;

  background:#EB9316;

  margin:0 0 5px 0;

  }

  .bt>li{

  float:left;

  width:265px;

  height:20px;

  text-align: center;

  line-height: 20px;

  font-size:13px;

  }

  .nr{

  float:left;          /*如果不浮動 后面的lynr會受影響*/

  width:799px;

  height:20px;

  text-align: center;

  background:#B9DEF0;

  }

  .nr>li{

  float:left;

  width:265px;

  height:20px;

  text-align: center;

  line-height: 20px;

  font-size:13px;

  }

  .lynr{

  float:left;    /*如果不浮動會 布局會亂*/

  width:800px;

  margin:1px 0 1px 0;

  }

  .content p{

  width:70px;

  height:50px;

  float:left;

  }

  .content span{

  display: block;

  width:710px;

  float:left;

  }

  td{

  width:80px;

  padding:5px 0;

  /*border: 1px solid #79ABFE;*/

  }

  td input,textarea{

  border: 1px solid #79ABFE;

  }

  /*tr{

  display:block;       /*將tr設(shè)置為塊體元素 顯示塊狀后 就將其包圍住了 不是一個矩形了

  }*/

  dist/css/bootstrap.min.css(自己下載)

  下載地址:http://pan.baidu.com/s/1hrK3Dpq

【PHP簡單留言本功能的實現(xiàn)代碼】相關(guān)文章:

PHP滾動日志的代碼實現(xiàn)05-17

php實現(xiàn)無限級分類實現(xiàn)代碼07-03

PHP中如何實現(xiàn)crontab代碼05-30

php學(xué)習(xí)之簡單計算器實現(xiàn)代碼01-23

php的curl實現(xiàn)get和post的代碼07-07

php進度條實現(xiàn)代碼04-05

PHP實現(xiàn)大文件上傳源代碼05-03

PHP入門需要掌握的幾種功能代碼03-16

php使用ftp函數(shù)實現(xiàn)簡單上傳功能02-07

主站蜘蛛池模板: 丹寨县| 鄱阳县| 邵东县| 贡嘎县| 长子县| 桂阳县| 定安县| 怀远县| 涟水县| 佳木斯市| 紫阳县| 古蔺县| 广水市| 五常市| 乌拉特后旗| 庆安县| 无极县| 尚义县| 剑河县| 青岛市| 新乐市| 合川市| 鄄城县| 津南区| 白玉县| 芜湖县| 屏山县| 明星| 巴塘县| 屯留县| 宜春市| 马公市| 巨鹿县| 九龙县| 新民市| 嵩明县| 宁安市| 盐亭县| 西藏| 上饶县| 渝中区|