我是PHP的初学者,这是我的代码
<h3 class="green">Generate Report</h3>
<p>Please select the date range of the report you wish to print.</p>
<form id="generate-pdf" action="print.php" method="post">
<table class="activate-res">
<tr>
<td><p class="form-type-left">Course Activity:</p>
<select id="" name="courseActivity" class="dropdown" >
<option value="">--Unspecified--</option>
<option value="all">All time</option>
<option value="7">Last 7 days</option>
<option value="30">Last 30 days</option>
</select>
</td>
</tr>
</table>
<?php if (isset($_SESSION["site_admin"]) && (int) $_SESSION["site_admin"]) { ?>
<h3 class="green">Select site(s)</h3>
<p>Please select which sites to include in the report.</p>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$('#select-all').on('change', function() {
$('.listSite input[type="checkbox"]').prop('checked', this.checked);
});
$('.listSite input[type="checkbox"]').on('change', function () {
var allChecked = $('.listSite input:checked').length === $('.listSite input').length;
$('#select-all').prop('checked', allChecked);
});
});//]]>
</script>
<table class="err_highlight activate-res" style="border:1px solid #fff">
<tr>
<td><input type="checkbox" value="All Sites" id="select-all" name="selectSite"></td>
<td>All Sites</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Chilterns"></td>
<td>Chilterns</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Fakenham"></td>
<td>Fakenham</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Grimsby"></td>
<td>Grimsby</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Head Office"></td>
<td>Head Office</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Headcorn"></td>
<td>Headcorn</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Histon"></td>
<td>Histon</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Killingbeck"></td>
<td>Killingbeck</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Luton"></td>
<td>Luton</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Waterside Park"></td>
<td>Waterside Park</td>
</tr>
<tr>
<td class="listSite"><input name="selectSite" type="checkbox" value="Westwood"></td>
<td>Westwood</td>
</tr>
</table>
<?php } ?>
<!-- onClick="document.location.href='template.php'" -->
<table class="activate-res">
<tr>
<td><input name="submit" type="submit" value="Generate Report" class="log-button" /></td>
<td><input name="cancel" type="button" value="Cancel" class="log-button" onClick="document.location.href='admin-serials.php'" /></td>
</tr>
</table>
</form>
</div><!-- content -->
</div><!-- wrapper -->
<?php include('footer.php') ?>
这是我的数据生成代码,但这个静态我想动态输出怎么可能改变?如果我选择全部然后他们得到并显示所有网站数据从数据库或如果我选择7或30天然后他们得到并显示7或30天数据,并且以下10个网站显示静态,但他们也动态变化如果我选中复选框全部或我选择选中然后单击以生成数据。这意味着我选择Westwood然后他们只获得数据westwood或者我选择all然后他们获得所有数据显示。
答案 0 :(得分:0)
你需要获取请求变量并为每个循环放入一个mysql where子句并在循环中显示结果。
例如:
$where = '';
foreach ($requests as $req)
{
$where .= ' where {$column_name} = {$req}';
}
$result = 'select * from table ' . $where;
//and loop in HTML
foreach ($result as $item)
{
echo $item. '<br />';
}
由于 阿迪尔