我想做一个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查询 –