候选人DB - Kandidater
(`id`, `name`, `department_id`) VALUES
(7, 'Kandidat 1', 0),
(8, 'Kandidat 2', 0),
(9, 'Kandidat 3', 0),
(10, 'Clarissa F. Andersen', 5000),
(11, 'Sandra Flammild', 5000),
(12, 'Amina Nielsen', 5000),
(13, 'Lise Lundin', 5000),
(14, 'Katrine Skovsgaard', 5000),
(15, 'Helle Lieesol Haugaard', 5000),
(16, 'Alicia Macaulau', 5000),
(17, 'Mark Mikel Thygesen', 5000),
(18, 'Michelle Møller', 5000),
(19, 'Nadia Chaker', 5000),
周计划DB - Ugeplan
(`ID`, `K_ID`, `man_k`, `tir_k`, `ons_k`, `tor_k`,
`fre_k`, `man_g`, `tir_g`, `ons_g`, `tor_g`, `fre_g`,
`man_s`, `tir_s`, `ons_s`, `tor_s`, `fre_s`, `DM`, `DT`,
`DON`, `DTO`, `DF`, `uge`)
VALUES (2, 7, '09:00:00', '00:00:00', '00:00:00', '12:00:00',
'00:00:00', '12:00:00', '00:00:00', '00:00:00', '16:00:00',
'00:00:00', '', 'Fri', 'Fri', '', 'Syg', '19-06-2017',
'20-06-2017', '21-06-2017', '', 'Syg', 25),
(3, 7, '09:00:00', '00:00:00', '00:00:00', '12:00:00',
'00:00:00', '12:00:00', '00:00:00', '00:00:00', '16:00:00',
'00:00:00', '', 'Fri', 'Fri', '', 'Syg', '19-06-2017',
'20-06-2017', '21-06-2017', '', '23-06-2017', 25)
说明:
<?php
if(isset($_GET['city'])){
$by = $_GET['city'];
$dato = date('d/m/Y');
$idag = date("D");
$currentweek = date("W");
//Setting the right mysql table variables
$komme = '';
if($idag == Mon){$komme = "man_k"; $datoen = 'DM';}
else
if($idag == Tue){$komme = "tir_t"; $datoen = 'DT';}
else
if($idag == Wed){$komme = "ons_k"; $datoen = 'DON';}
else
if($idag == Thu){$komme = "tor_k"; $datoen = 'DTO';}
else
if($idag == Fri){$komme = "fre_k"; $datoen = 'DF';}
$connection = new mysqli('host', 'username', 'password', 'DB')
or die ('Cannot connect to db');
?>
<div style="float: left; width: 200px; min-height: 120px; border: 1px solid black;">
<h3>Kandidater i dag</h3>
<?php
//Getting list off candidates to the preselected department
$results = $connection->query("select * from kandidater where afdeling_id = $by");
while ($rows = $results->fetch_assoc()) {
$id = $rows['id'];
$person = $rows['navn'];
//Checking if they are planned to arrive today
$sql = "select $komme from ugeplan where K_ID ='$id' and $datoen = '$dato'";
$result = $connection->query($sql);
$row = $result->fetch_assoc();
$vis = $row[$komme];
if($vis == '00:00:00'){}else{
echo $person . "<br/>";
}
}
?>
</div>
<?php
}
?>
我知道这是一段糟糕的代码,但我可以稍后清理它,我只需要弄清楚我做错了什么。
关键在于我建立了一个注册到达和离开工作的网站。 每个候选人都应该能够办理入住/退房等工作。这已经有效,并且正在接受测试。
在同一屏幕上,指定的领导者希望能够快速查看计划今天到达的人,然后留意该人,或者给他们打电话。 同样在紧急情况下,他们希望能够通过查看系统轻松检查每个人是否被占用。
答案 0 :(得分:0)
您需要在PHP的开头更改此行:
$dato = date('d-m-Y');
因为您的$ dato和'd-m-Y'格式的'd / m / Y'日期格式在您的周计划DB - Ugeplan表中。 无论如何,在您的数据库中,您应该使用DATE格式而不是varchar来保存日期列