我正在尝试从按钮的 onclick() 事件运行上述语句。我可以$qtr, $saleqtr, $startdate, $enddate
在屏幕上回显我的变量,但由于某种原因,我试图放在一起的 sql 语句从不回显(也不执行,这就是我想查看字符串的原因)。
我有一个简单的语法错误还是其他地方的问题?
<?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;
}
?>
编辑
下面是我的点击事件
<body>
<form method="POST">
<input type="submit" name="submit" value="Click Me">
</form>
</body>