任何人都可以帮我吗?我只想使用javascript打印模式打印此表。但是怎么样?还使用Web样式中的打印视图。我非常感谢任何帮助。先感谢您。 :)
这是我的代码。
<?php
if(isset($_POST['search'])) {
$valueToSearch = $_POST['valueToSearch'];
$query = "SELECT * FROM dailytimerecord WHERE CONCAT(Dtrec_ID, TimeIn, TimeOut) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
} else {
$query = "SELECT * FROM dailytimerecord";
$search_result = filterTable($query);
}
function filterTable($query) {
$connect = mysqli_connect("localhost", "root", "", "alqdb");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP HTML TABLE DATA SEARCH</title>
<style>
table,tr,th,td {
border: 1px solid black;
}
</style>
</head>
<body>
<form method="post">
<input type="text" name="valueToSearch" placeholder="Value To Search"><br><br>
<input type="submit" name="search" value="Filter"><br><br>
<input type="button" name="print" value="Print"><br><br>
<table>
<tr>
<th>Name</th>
<th>Dtrec_ID</th>
<th>Date</th>
<th>Time In</th>
<th>Time Out</th>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td></td>
<td><?php echo $row['Dtrec_ID'];?></td>
<td><?php echo date("F j, Y", strtotime($row['TimeIn']));?></td>
<td><?php echo date("h:i, A", strtotime($row['TimeIn']))?></td>
<td><?php echo date("h:i, A", strtotime($row['TimeOut']));?></td>
</tr>
<?php endwhile;?>
</table>
</form>
</body>
</html>