我正在努力使用过滤器。我正在尝试创建一个页面,其中包含具有多个类别的复选框列表。单击该框后,它将从mysql中检索结果。其中一个类别有一个数组。这是我的HTML
<div id="options-list">
<table>
<tr><td>
<label for="newstype">News:</label>
</td></tr>
<tr><td>
<input class="cb" type="checkbox" id="test" name="newstype[]" value="Generic News" checked=""/> Generic News<br />
<input class="cb" type="checkbox" id="test" name="newstype[]" value="Top News" /> Top News<br />
</td></tr>
<tr><td>
<label for="category">Category: </label>
</td></tr>
<tr><td>
<input class="cb" type="checkbox" id="test" name="category[]" value="Economy" checked=""/> Economy<br />
<input class="cb" type="checkbox" id="test" name="category[]" value="Economic Indicators" /> Economic Indicators<br />
<input class="cb" type="checkbox" id="test" name="category[]" value="Central Banks" /> Central Banks<br />
</td></tr>
<tr><td>
<label for="regions">Regions:</label>
</td></tr>
<tr><td>
<input class="cb" type="checkbox" id="test" name="regions[]" value="EMU & Nordic" checked=""/> EMU & Nordic<br />
<input class="cb" type="checkbox" id="test" name="regions[]" value="UK" /> UK <br />
<input class="cb" type="checkbox" id="test" name="regions[]" value="North America" /> North America<br />
</td></tr>
<tr><td>
<label for="timezones">Time Zones:</label>
</td></tr>
<tr><td>
<input class="cb" type="checkbox" id="test" name="timezone[]" value="EMEA Mkt Hours" checked=""/> EMEA Mkt Hours<br />
<input class="cb" type="checkbox" id="test" name="timezone[]" value="US Mkt Hours" /> US Mkt Hours<br />
</td></tr>
<tr><td>
<label for="articletype">News Type:</label>
</td></tr>
<tr><td>
<input class="cb" id="test" name="articletype[]" value="News" type="checkbox" checked=""> News<br />
<input class="cb" id="test" name="articletype[]" value="Views" type="checkbox"> Views<br />
</td></tr>
</table>
</div>
<div class="headlines">
<h1>HEADLINES</h1>
<div class="block" id="newsdisplay">
<table class="tableNews">
<script type="text/html" id="headlines-temp">
<tr>
<td width="75px"> </td>
<td><div data-bind="text:headline"></div></td>
</tr>
</script>
<div class="example"> <? list_newsfeed(); ?></div>
这是我的mysql函数:
function list_newsfeed() {
$perpage=25;
if (isset($_GET["page"])) {
$page = $_GET["page"];
} else {
$page=1;
};
$start_from = ($page-1) * $perpage;
$result = mysql_query("SELECT * FROM headnews ORDER BY news_date DESC, news_time DESC LIMIT $start_from, $perpage");
$rowColors = Array('rgba(0,0,0,0.22)', 'none'); $nRow = 0;
while ($row = mysql_fetch_array($result)) {
echo "<tr style=\"background-color:".$rowColors[$nRow++ % count($rowColors)]."\"><td width=\"75px\">".$row['news_time']. "</td><td> " .$row['name']. "</td></tr>";
}
$rs_result = mysql_query("SELECT COUNT(id) FROM headnews");
$row = mysql_fetch_row($rs_result);
$total_headnews = $row[0];
$total_pages = ceil($total_headnews / $perpage);
$pagLink = "<div class=\"pagination\">";
for ($i=1; $i<=$total_pages; $i++) {
$pagLink .= "<a href=\"headnews.php?page=".$i."\">".$i."</a> ";
}
echo $pagLink . "</div>";
}