-3
我有我的第一個網站在PHP中,用戶可以顯示員工的生物指標日誌,他們可以通過在組合列表,並選擇操作哪個部門應該在表格中顯示開發可以通過excel輸出。現在我想使用日期2時間選擇器篩選日期範圍內的數據,有人可以向我展示一些鏈接或示例,可以很容易地瞭解像我這樣的新手。下面是我的index.php
的index.php
<?php
$conn =mysqli_connect("localhost", "root", "", "bio_db");
function filterTable($sql)
{
$connect = mysqli_connect("localhost", "root", "","bio_db");
$filter_Result = mysqli_query($connect, $sql);
return $filter_Result;
}
$post_at = "";
$post_at_to_date = "";
$queryCondition = "";
if(isset($_POST["search"]["post_at"])) {
$post_at = $_POST["search"]["post_at"];
list($fid,$fim,$fiy) = explode("-",$post_at);
$post_at_to_date = date('Y-m-d');
if(isset($_POST["search"]["post_at_to_date"])) {
$post_at_to_date = $_POST["search"]["post_at_to_date"];
list($tiy,$tim,$tid) = explode("-",$_POST["search"] ["post_at_to_date"]);
$post_at_to_date = "$tiy-$tim-$tid";
}
$queryCondition .= "Where post_at BEETWEEN '$fiy-$fim-$fid' AND '" .$post_at_to_date. "'";
}
else { $sql = "SELECT * from daily_data2 " .$queryCondition. " ORDER BY post_at ASC";
$search_result = filterTable($sql);
}
?>
<html>
<head>
<title>Time and Attendance Monitoring</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<style>
.table-content{border-top:#CCCCCC 4px solid; width:50%;}
.table-content th {padding:5px 20px; background: #F0F0F0;vertical-align:top;}
.table-content td {padding:5px 20px; border-bottom: #F0F0F0 1px solid;vertical-align:top;}
</style>
</head>
<body>
<div class="demo-content">
<h2 class="title_with_link">Time and Attendance Monitoring</h2>
<form name="frmSearch" method="post" action="index.php">
<p class="search_input">
<input type="text" placeholder="From Date" id="post_at" name="search[post_at]" value="<?php echo $post_at; ?>" class="input-control" />
<input type="text" placeholder="To Date" id="post_at_to_date" name="search[post_at_to_date]" style="margin-left:10px" value="<?php echo $post_at_to_date; ?>" class="input-control" />
<input type="submit" name="go" value="Search" >
</p>
<?php if(!empty($result)) { ?>
<table align="center" width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Userid</th>
<th>Name</th>
<th>Campaign</th>
<th>Date</th>
<th>Hoursworked</th>
<th>Overtime</th>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td style="text-align:center;"><?php echo $row['Userid'];?></td>
<td width="200"><?php echo $row['Name'];?></td>
<td style="text-align:center;"><?php echo $row['Campaign'];?> </td>
<td width="100" style="text-align:center;"><?php echo $row['Date'];?></td>
<td style="text-align:center;"><?php echo $row['Hoursworked'];?></td>
<td style="text-align:center;"><?php echo $row['Overtime'];?> </td>
</tr>
<?php endwhile;?>
</table>
<?php } ?>
</form>
</div>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$.datepicker.setDefaults({
showOn: "button",
buttonImage: "datepicker.png",
buttonText: "Date Picker",
buttonImageOnly: true,
dateFormat: 'yy-mm-dd'
});
$(function() {
$("#post_at").datepicker();
$("#post_at_to_date").datepicker();
});
</script>
</body>
</html>
尊敬的Seryu,歡迎來到stackovweflow,請參閱如何提問問題,以及您的代碼在哪裏,您到目前爲止所嘗試的內容。給我的鏈接或例子不是stackoverflow的。 – karan
請參閱我的代碼的編輯 – Seryu
只是一個小的offtop。強烈建議閱讀SQL注入和https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project。 – Alex