我一直在阅读并寻找解决我当前问题的方法,但没有运气。我目前有一个PHP页面,可完美地将MySQL的日期从MySQL中获取到下拉表中,但是选择它时,我将带我进入结果页面,并且没有显示任何内容。如果有人可以帮助我,我将不胜感激。
这是选择代码:
<div class="span6" style="text-align: center">
<h4 style="text-align: center">Monthly Tax Search</h4>
<br>
<table>
<thead>
</thead>
</table>
<form action="tax-monthly-report.php" method="post">
<?php
$query = "select date_format(date,'%b %Y') 'date',SUM(siit.tax_amount) 'tax_amount',st.tax_description 'tax_description'
from si_invoices si
inner join si_invoice_items sii on si.id = sii.invoice_id
inner join si_invoice_item_tax siit on sii.id = siit.invoice_item_id
inner join si_tax st ON siit.tax_id = st.tax_id
GROUP BY date_format(date,'%b %Y')";
$result = mysql_query($query) or die (mysql_error());
echo '<select name="date">';
while ($row = mysql_fetch_assoc($result)) {
echo "<option value='" . $row['date'] ."'>" . $row['date'] ."</option>";
}
echo '</select>';
echo '<br><input type="submit" class="btn btn-success" name="SUBMIT" value="Submit" />
<input type="reset" class="btn btn-danger" name="RESET" value="Cancel" />';
?>
</form>
</div>
所以在这里您可以看到,即使它确实有完整的查询,也只能选择将与另一页上的表一起引用的日期,这是结果页面的代码:
<div class="row">
<div class="span6" style="text-align: center">
<h4 style="text-align: center">Monthly Tax Search</h4>
<br>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Date</th>
<th>Tax Type</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?
$date = $_POST['date'];
$query = "select date_format(date,'%b %Y') 'date',SUM(siit.tax_amount) 'tax_amount',st.tax_description 'tax_description'
from si_invoices si
left join si_invoice_items sii on si.id = sii.invoice_id
left join si_invoice_item_tax siit on sii.id = siit.invoice_item_id
left join si_tax st ON siit.tax_id = st.tax_id
WHERE date = '".mysql_real_escape_string($date)."'
GROUP BY st.tax_description,date_format(date,'%b %Y')";
if($num_result == 1) {
echo '<b>ERROR</b>';
}
$result =mysql_query($query) or die (mysql_errno());
while($row = mysql_fetch_assoc($result)) {
echo ' <tr>
<td>' . $row['date'] . '</td>
<td>' . $row['tax_description'] . '</td>
<td style="text-align: right">'."$ " . number_format($row['tax_amount'],2) . '</td>
</tr>';
}
?>
</tbody>
</table>
</div>