我目前正在使用SQL数据库进行“待办事项列表”项目。 这是我的问题;当我添加新任务时,它会出现在待办事项列表中,也出现在状态为0的数据库中(待办事项)。 当我选中复选框并按“完成”按钮使其进入状态 - >完成后,数据库中的状态发生变化(从0到1),但另一方面不会更改网页中的任何空间以便在归档中可见。有人可以帮帮我吗? 这是我的代码的副本;
在“新任务”部分的html代码中,可以为输入的每个新任务显示新代码;
<?php
$recu = $dtb->query("SELECT*FROM taches");
$recup = $recu->fetchAll();
foreach($recup as $value){
echo"<label class='tache'><input type='checkbox' name='ligne[]' value='".$value['ID']."'><p>".$value['Date1']." at ".$value['Date2']." and ".$value['Hour1']." at ".$value['Hour2']." : ".$value['Task']."</p></label><br/>";}
;?>
部分“Archives”,不包含php代码,因为我不知道告诉它要显示刚刚修改过的任务。
代码php;<?php
try {
$dtb = newPDO('mysql:host=localhost;dbname=todolist;charset=utf8', 'root', '' );
} catch(PDOException$machin){
echo$machin -> getMessage();
}
// if(isset($_POST["ajouter"])){
if(true){
$option = array(
'ligne' => FILTER_SANITIZE_STRING | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_NUMBER_INT,
'addnew' => FILTER_SANITIZE_STRING | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_NUMBER_INT,
'datea' => FILTER_SANITIZE_NUMBER_INT,
'dateb' => FILTER_SANITIZE_NUMBER_INT,
'hour1' => FILTER_SANITIZE_NUMBER_INT,
'hour2' => FILTER_SANITIZE_NUMBER_INT,
'ajouter' => FILTER_SANITIZE_STRING | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_NUMBER_INT,
'done' => FILTER_SANITIZE_STRING | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_NUMBER_INT,
'delete' => FILTER_SANITIZE_STRING | FILTER_FLAG_NO_ENCODE_QUOTES | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP | FILTER_SANITIZE_NUMBER_INT
);
$result = filter_input_array(INPUT_POST, $option);
$add = $result["addnew"];
$datea = $result["datea"];
$dateb = $result["dateb"];
$houra = $result["hour1"];
$hourb = $result["hour2"];
$aj = $result["ajouter"];
$don = $result["done"];
$del = $result["delete"];
$line = $result["ligne"];
if(isset($result) && !empty($result)){
if(isset($add) && isset($aj)){
$dtb->query('INSERTINTO taches (Date1, Date2, Hour1, Hour2, Task, Stat) VALUES ("'.$datea.'", "'.$dateb.'", "'.$houra.'", "'.$hourb.'", "'.$add.'", 0)');
}
if(isset($_POST['ligne']) && isset($don)){
$dtb->exec('UPDATE taches SET Stat=1WHERE ID='.$_POST['ID'].'');
}
if(isset($check) && isset($del)){
$dtb->query('DELETEFROM taches');
}
}
}
?>