php留言板更新代碼

來源:互聯網
上載者:User

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$lianjie = mysql_connect("localhost","root","xiaolie") or die("串連失敗");
mysql_query("set names utf8");
if($lianjie)
{
 mysql_select_db("xiaolie");
 if(!$_GET)
 {
  $xuanbiao = "select * from zhuce";
  $fasong = mysql_query($xuanbiao) or die(mysql_error());
  echo "<table border=1>
    <tr>
     <td>編號</td>
     <td>使用者名稱稱</td>
     <td>性別</td>
     <td>年齡</td>
     <td>註冊時間</td>
     <td>操作</td>
    </tr>";
  while($nr=mysql_fetch_array($fasong))
  {
   echo "<tr>
     <td>".$nr["id"]."</td>
     <td>".$nr["name"]."</td>
     <td>".$nr["xingbie"]."</td>
     <td>".$nr["nianling"]."</td>
     <td>".$nr["zc_shijian"]."</td>
     <td><a href=gx_my.php?id=".$nr["id"].">編輯</a></td>
    </tr>";
  }
  echo "</table>";
 }
 else
 {
  if(!$_POST)
  {
   $xianid = "select * from zhuce where id=".$_GET["id"];
   $fasong = mysql_query($xianid) or die(mysql_error());
   $nr = mysql_fetch_array($fasong);
   ?>
            <form method=post action="gx_my.php?id=<?php echo $_GET["id"];?>">
            <?php
             echo $nr["id"]."<br>";
   ?>
            <input type="hidden" name="id" value=<?php echo $nr["id"];?>>
            姓名<input type="text" name="name" value=<?php echo $nr["name"];?>><br>
            性別<input type="text" name="xingbie" value=<?php echo $nr["xingbie"];?>><br>           
            年齡<input type="text" name="nianling" value=<?php echo $nr["nianling"];?>><br>
            註冊時間<input type="text" name="zc_shijian" value=<?php echo $nr["zc_shijian"];?>><br>
            <input type="submit" name="ok" value="提交">
            </form>
            <?php
  }
  else
  {
   $gx = "update zhuce set name='".$_POST["name"]."',xingbie='".$_POST["xingbie"]."',nianling='".$_POST["nianling"]."',zc_shijian='".$_POST["zc_shijian"]."' where id='".$_POST["id"]."'";
   $fasong = mysql_query($gx);
   if($fasong){
    echo "記錄已經成功修改<br><a href=gx_my.php>繼續修改記錄</a>";}
   else{
    echo "記錄修改失敗<br><a href=gx_my.php?id=".$_POST["id"].">返回</a>"; } 
  }
 }
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.