Todolist--(7)顯示列表

list.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>計(jì)劃頁面</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
    <body>
        <?php
        session_start();
        echo"{$_SESSION['username']},歡迎來到你的計(jì)劃列表 ";
        echo"<br />";
        $dbc=@mysqli_connect('127.0.0.1', 'root','123456','todolist') 
            or die('could not connect to mysql');
        mysqli_set_charset($dbc,'utf8');
       if($_SERVER['REQUEST_METHOD']=='POST'){
       if($_POST['orderhidden']=='a'){
        if(!empty($_POST['content'])){
            $content=$_POST['content'];
            $p="insert into listmessage (content ,user_id) values (\"$content\",\"{$_SESSION['user_id']}\")";
            @mysqli_query($dbc,$p);
            $r=mysqli_affected_rows($dbc);
            echo $r;
            if($r<=0)
                {
                echo "添加失敗";
            }
        }else{
            echo"請?zhí)砑觾?nèi)容";           
        } 
    }
    }
    if($_SERVER['REQUEST_METHOD']=='POST'){
        //if($_POST['orderhidden']=='b'){
    $list_id=$_POST['hidden'];
    $q="delete from listmessage where list_id='$list_id'";
    $r=mysqli_query($dbc,$q);
    if(!$r){
        echo"請重新點(diǎn)擊刪除";
        //echo mysqli_error($dbc);
    }
   // }   
    }
      $q="select content,list_id from listmessage where user_id={$_SESSION['user_id']}";
        $s=mysqli_query($dbc,$q);
        $num=mysqli_num_rows($s);
       if($s){
         //$order=0;
        
         echo'您有'.$num.'條計(jì)劃';
         echo'<br />';
         echo'您有'.$num.'個(gè)計(jì)劃編碼';
        echo'<table align="center" border="3">';
      while($row=mysqli_fetch_array($s,MYSQLI_ASSOC)){
                echo'<tr><td>'.$row['content'].
                ' <form action="list.php" method="POST">
                <input type="hidden" name="hidden" value='.$row['list_id'].'>
               <input type="hidden" name="orderhidden" value="b" />
                <input type="submit" value="刪除" />
                </form>
                </td></tr>';
            }
        echo'<tr><td>
             <form action="list.php" method="POST">
          內(nèi)容:<textarea name="content" cols="30" rows="3"></textarea>
         <br />
        <input type="submit" value="添加" />
        <input type="hidden" name="orderhidden" value="a" />
         </form>
        </td></tr>'; 
        echo'</table>';
    }  
        ?>  
        <a href="logout.php">注銷</a>
        <br />
        <a href="changepassword.php">更改密碼</a>
        <br />
         <a href="index.php">返回首頁</a>
    </body>
    </html>

此項(xiàng)目的完整代碼可以到我的github,todolist進(jìn)行下載。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,058評論 25 709
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,569評論 19 139
  • 前幾天看到一個(gè)推送,給我的感觸很深,所以來出來說一說。 很多人習(xí)慣性的會(huì)說自己有什么什么癥,一遇到點(diǎn)不開心的事,就...
    夢也夏雪閱讀 265評論 1 0
  • 森美最近心情實(shí)在不太好。窗外的陽光實(shí)在有點(diǎn)晃眼。她下了班盤腿坐在床上,望著窗外的樹葉搖曳發(fā)起了呆。最近工作繁重,每...
    我是長今閱讀 408評論 0 2
  • 感恩親人感謝爸媽
    色彩愛好者閱讀 203評論 0 0

友情鏈接更多精彩內(nèi)容