Date Picker External Report

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
mwilliam
Veteran Member
Posts: 32
Joined: 2018-03-31 09:03
Location: London, Kentucky

Date Picker External Report

Post by mwilliam » 2018-04-29 15:55

Could someone help me add the ability to be able to search by a date criteria.







<?php
$db_host = 'localhost'; // Server Name
$db_user = 'admin'; // Username
$db_pass = ''; // Password
$db_name = 'lcso'; // Database Name

$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}

$sql = 'SELECT *
FROM accident';

$query = mysqli_query($conn, $sql);

if (!$query) {
die ('SQL Error: ' . mysqli_error($conn));
}
?>
<html>
<head>
<title>Accident Report</title>
<style type="text/css">
body {
font-size: 15px;
color: #343d44;
font-family: "segoe-ui", "open-sans", tahoma, arial;
padding: 0;
margin: 0;
}
table {
margin: auto;
font-family: "Lucida Sans Unicode", "Lucida Grande", "Segoe Ui";
font-size: 12px;
}

h1 {
margin: 25px auto 0;
text-align: center;
text-transform: uppercase;
font-size: 17px;
}

table td {
transition: all .5s;
}

/* Table */
.data-table {
border-collapse: collapse;
font-size: 14px;
min-width: 537px;
}

.data-table th,
.data-table td {
border: 1px solid #e1edff;
padding: 7px 17px;
}
.data-table caption {
margin: 7px;
}

/* Table Header */
.data-table thead th {
background-color: #508abb;
color: #FFFFFF;
border-color: #6ea1cc !important;
text-transform: uppercase;
}

/* Table Body */
.data-table tbody td {
color: #353535;
}
.data-table tbody td:first-child,
.data-table tbody td:nth-child(4),
.data-table tbody td:last-child {
text-align: right;
}

.data-table tbody tr:nth-child(odd) td {
background-color: #f4fbff;
}
.data-table tbody tr:hover td {
background-color: #ffffa2;
border-color: #ffff0f;
}

/* Table Footer */
.data-table tfoot th {
background-color: #e5f5ff;
text-align: right;
}
.data-table tfoot th:first-child {
text-align: left;
}
.data-table tbody td:empty
{
background-color: #ffcccc;
}
</style>
</head>
<body>
<h1>LCSO REPORT</h1>
<table class="data-table">
<caption class="title">Accident Reports</caption>
<thead>
<tr>
<th>Code</th>
<th>Parties Involved</th>
<th>Location</th>
<th>Date</th>
<th>Unit</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
while ($row = mysqli_fetch_array($query))
{
echo '<tr>
<td>'.$no.'</td>
<td>'.$row['parties'].'</td>
<td>'.$row['location'].'</td>
<td>'. date('F d, Y', strtotime($row['date1'])) . '</td>
<td>'.$row['unit1'].'</td>

</tr>';
$total += $row['type'];
$no++;
}?>
</tbody>
<tfoot>
<tr>
</tr>
</tfoot>
</table>
</body>
</html>

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: Date Picker External Report

Post by baudwalker » 2018-04-30 06:51

Hi,
The basic date search looks like this. assuming that the date is stored yyyymmdd

****************************************************
<form action="" method="post">
<br><br>
<h1>input date </h1>
yyyymmdd no spaces
<br><br>
<input type="text" name="date" />

<input type="submit" />
<input type="reset" />
<br><br>
</form>

<?php

$sql = 'SELECT * FROM accident WHERE date1=$_POST[date]';

?>

mwilliam
Veteran Member
Posts: 32
Joined: 2018-03-31 09:03
Location: London, Kentucky

Re: Date Picker External Report

Post by mwilliam » 2018-04-30 16:49

Would that be a good place to put in a hook ?

Post Reply