我想做一個PHP文件來搜索我的數據庫表「考勤」。
我想從一個日期的值到另一個日期。PHP的 - 如何使搜索引擎從日期搜索到另一個日期
例如, |日期1 | |日期2 |
|從date1到date2顯示的值|
我的表包含emp_id
,Date
,Day
,Time_In
,Time_Out
,Worked
,Overtime
,Less_Hours
,Transport_In
,Transport_Out
。
我希望有人能幫助我。 在此先感謝
編輯1:
<?php
require_once 'Connection.simple.php';
$conn = dbConnect();
$OK = true;
if (isset($_GET['employee_id'])) {
$data = "%".$_GET['employee_id']."%";
$sql = 'SELECT * FROM employee WHERE employee_id like ?';
$stmt = $conn->prepare($sql);
$results = $stmt->execute(array($data));
$rows = $stmt->fetchAll();
$error = $stmt->errorInfo();
}
if(empty($rows)) {
echo "<tr>";
echo "<td colspan='4'>There were not records</td>";
echo "</tr>";
}
else {
foreach ($rows as $row) {
echo "<tr>";
echo "<td>".$row['employee_id']."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['telephone']."</td>";
echo "</tr>";
}
}
?>
我曾嘗試這個簡單的代碼在我的數據庫表中進行搜索,但我不知道該怎麼走的更遠。 我只是一個初學者
RGDS
Akshat
EDIT 2
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.btnSearch').click(function(){
makeAjaxRequest();
});
$('form').submit(function(e){
e.preventDefault();
makeAjaxRequest();
return false;
});
function makeAjaxRequest() {
$.ajax({
url: 'php/search.php',
type: 'get',
DateFrom: {DateFrom: $('input#DateFrom').val()},
DateTo: {DateTo: $('input#DateTo').val()},
success: function(response) {
$('table#resultTable tbody').html(response);
}
});
}
});
</script>
這是我使用的index.html頁面上
RGDS
Akshat代碼
您可以對此使用SQL查詢... – randomizer
對BETWEEN使用SQL查詢 –