I am attempting to run the above statement from an onclick() event of a button. I can echo my variables $qtr, $saleqtr, $startdate, $enddate
on screen but for some reason the sql statement that I am attempting to throw together never echo (nor does it execute, which is why I want to see the string).
Do I have a simple syntax mistake or is the issue elsewhere?
<?php
if (isset($_POST['submit'])) {
$saleqtr = $_POST['qtr'];
if ($saleqtr == "first") { $startdate = '20150101'; $enddate = '20150331'; }
if (isset($startdate) && isset($enddate)) {
$customername = $_POST['customer'];
$option = array();
$option['driver'] = 'mssql';
$option['host'] = 'X';
$option['user'] = 'user';
$option['password'] = 'pass';
$option['database'] = 'db';
$option['prefix'] = '';
$db = JDatabase::getInstance($option);
$sql = $db->getquery(true);
$sql = "SELECT Top 1 name from name where hiredate >= '$startdate' And hiredate <= '$enddate'";
}
echo $sql;
}
?>
EDIT
Below is my click event
<body>
<form method="POST">
<input type="submit" name="submit" value="Click Me">
</form>
</body>