我有一个搜索按钮,用于搜索报告输入日期。但是当我点击按钮时,即使我正确输入了开始和结束日期,表格也显示为空。
PHP代码
<?php
include('konek.php');
$start = isset($_GET['d1']) ? $_GET['d1'] : '';
$end = isset($_GET['d2']) ? $_GET['d2'] : '';
if (isset($_GET['submit']) && $_GET['submit']=='Search') {
$result = mysql_query("SELECT
t1.qty, t2.lastname, t2.firstname, t2.date, t3.name,
t2.reservation_id, t2.payable FROM prodinventory AS t1
INNER JOIN reservation AS t2
ON t1.confirmation=t2.confirmation
INNER JOIN products AS t3
ON t1.room=t3.id
WHERE t2.date BETWEEN '$start' AND '$end'
GROUP BY t2.confirmation");
while ($row = mysql_fetch_array($result)){
echo'<tr class="record">';
echo'<td>'; echo $row['reservation_id']; echo'</td>';
echo'<td>'; echo $row['date']; echo'</td>';
echo'<td>'; echo $row['firstname'].' '.$row['lastname']; echo'</td>';
echo'<td>'; echo $row['name'].' '.$row['qty']; echo'</td>';
echo'<td>'; echo $row['payable']; echo'</td>';
echo'</tr>';
echo'</tbody>';
echo'</table>';
$result1 = mysql_query("SELECT SUM(payable) FROM reservation WHERE date BETWEEN '$d1' AND '$d2'");
while ($rows1 = mysql_fetch_array($result1)) {
?>
<div class="pull-right">
<div class="span">
<div class="alert alert-info"><i class="icon-credit-card icon-large"> </i> Sub Total: PHP <?php echo number_format(floatval($rows1['SUM(payable)'])); ? ></div>
</div>
</div>
</center>
<?php }}} ?>
这是我的HTML表单
<form action="salesreport.php" method="GET">
<input name="submit" id="submit" type="submit" class="btnsearch" value="Search" />
From : <input type="text" name="d1" id="d1" class="tcal" value="" />
To: <input type="text" name="d2" id="d2" class="tcal" value="" />
答案 0 :(得分:0)
<?php echo number_format(floatval($rows1['SUM(payable)'])); ? >
请检查代码。 PHP的关闭语法&#34;?&#34;和&#34;&gt;&#34;
答案 1 :(得分:0)
您很可能意味着$start
和$end
而不是$d1
或$d2
:
$result1 = mysql_query("SELECT SUM(payable)
FROM reservation
WHERE date BETWEEN '$start' AND '$end'");