所以我在服务器上有一个表格,可以保存用户输入的帖子。在您可以查看它们的最后一页上,您可以选择查看每个人的结果,或者选择只查看特定天气。选择某些天气部分正在工作,但如果您选择“全部”选项,它不会显示任何内容。任何想法是为什么?
View Posts
<br>
<form method="get" action="view_forum.php">
<label>Select Weather to Filter </label><br />
<select name="weather">
<option value="all">all</option>
<option value="cloudy">Cloudy</option>
<option value="sunny">Sunny</option>
<option value="windy">Windy</option>
<option value="snowy">Snowy</option>
<option value="mixy">Wintery Mix</option>
<option value="rainy">Rainy</option>
</select>
<input type="submit" value="view" />
</form>
<div id="view">
<center><img src="images/forum.png" width="589" height="97"></center>
</div>
<div id="white">
<div id="blue">
<div id="grey">
<div id="container">
<?php
$dbc = mysql_connect('html','user','password','database');
mysql_select_db('database',$dbc);
$weather = sanitize( $_GET["weather"] ); // keep your input clean
if ( $weather == "all" ) {
$sql = "SELECT * FROM stories ORDER BY id DESC";
} else {
$sql = "SELECT * FROM stories WHERE weather = '$weather' ORDER BY id DESC";
}
while( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
echo "<div class=\"names\"> {$row['name']}<br /></div>";
echo "<div class=\"weathers\">{$row['weather']}<br /></div>";
echo "<div class=\"stories\">{$row['story']}<br /></div>";
echo "<img src=\"images/line.png\" width='800' height='3'>";
echo "<br />";
}
?>
</div>
</div>
</div>
</div>