So, I'm hoping I get all the details for this one so it doesn't get bounced back to me. :)
I'm working on a personal project to track my call statistics. I've got the page itself done up, and some basic PHP (PDO)/MySQL code put in. What I'm trying to accomplish is having a page where I can put in start/end dates and have it populate the tables on the page with the information for that specified range.
This is the form section that has input boxes in it to type in the dates for the ranges, and underneath is the table where the data queried would populate:
This is the code from the agentstats.php file:
<?php
$startdate = $_POST['start_date']
$enddate = $_POST['end_date']
$yearstartdate = $_POST['year_start']
$yearenddate = $_POST['year_end']
$db = new PDO('mysql:host=localhost;dbname=mydb', 'myuser', 'mypassword');
$sql_overalltotalcalls = "SELECT count(*) FROM calldata WHERE DATE(`entrytimestamp`) = DATE_SUB(CURDATE(),INTERVAL 13 DAY)";
$overalltotalcalls = $db->query($sql_overalltotalcalls)->fetchColumn();
?>
<form>
<table>
<tr>
<th class="reportsettingscolors" colspan="2">Report Settings</th>
</tr>
<tr>
<td><label for="startdate">Report Start Date (Format: YYYY-MM-DD):</label></td>
<td><input type="text" name="start_date" id="startdate"></td>
</tr>
<tr>
<td><label for="enddate">Report End Date (Format: YYYY-MM-DD):</label></td>
<td><input type="text" name="end_date" id="enddate"></td>
</tr>
<tr>
<td><label for="yearstart">Year Start (Format: YYYY-MM-DD):</label></td>
<td><input type="text" name="year_start" id="yearstart"></td>
</tr>
<tr>
<td><label for="yearend">Year End (Format: YYYY-MM-DD):</label></td>
<td><input type="text" name="year_end" id="yearend"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Update"></td>
<tr>
</table>
</form>
<br>
<div class="container">
<div class="floatLeft">
<table>
<tr>
<th class="overallstatscolors" colspan="6">Overall Call Stats</th>
</tr>
<tr>
<th class="emptyblock"></th><th class="thisweekcolors">This Week</th><th class="lastweekcolors">Last Week</th><th rowspan="2">Weekly Difference</th><th rowspan="2">MTD</th><th rowspan="2">YTD</th>
</tr>
<tr>
<td class="emptyblock"></td>
<td><?php echo date("Y-m-d") ?></td>
<td><?php echo date('Y-m-d', strtotime('-7 days')) ?></td>
</tr>
<tr>
<td>Total Calls</td>
<td><?php echo $overalltotalcalls ?></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Total Transfers</td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>Transfer %</td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>Non-Live Calls</td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>Live Calls</td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>Total Call Time (Hrs)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>Total Wrap Time (Hrs)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>
</div>
Right now the $sql_overalltotalcalls query is manually configured to pull records 13 days prior to the current day. I did this just so I could test to see if it was all going to work. However, what I can't figure out is this:
How do I configure the code so that when I click on the "Update" button it takes the values from start_date and end_date and uses them in the $sql_overalltotalcalls query to count records between those dates?
I've tried adjusting the SQL to 'FROM calldata WHERE DATE('entrytimestamp') BETWEEN start_date and end_date' but that just breaks the code and jacks up how the page is displayed.
Also, forgive the empty sections. I'm working this one section at a time because most all the rest of the fields will be the same, with only slight modifications of the query.
Thanks!