1、对于每个checkbox设置表单域名字,在跳转后的页面通过表单域获取信息(通用的方法)
2、给每个checkbox空间设置name为一个数组的形式,比如:name="ck[]"
例如:checkbox组的代码如下:
<input type="checkbox" class="data" value="2011" id="2011" name="ck[]" />
<label for="2011">2011</label>
<input type="checkbox" class="data" value="2012" id="2012" name="ck[]" />
<label for="2012">2012</label>
<input type="checkbox" class="data" value="2013" id="2013" name="ck[]" />
<label for="2013">2013</label>
<input type="checkbox" class="data" value="2014" id="2014" name="ck[]" />
<label for="2014">2014</label>
<input type="checkbox" class="data" value="2015" id="2015" name="ck[]" />
<label for="2015">2015</label>
接收checkbox信息的代码:
$years = $_POST['ck'];
$years = implode(',', $years);
将其用在sql查询语句上:
if($years != null) $strsql = $strsql." and ct_time in (".$years.")";
查询ct_time在所选中的年份中集合。