当用户选择他的状态月份时,我试图创建一个动态下拉菜单,并且它搜索 mysql 数据库的年份,该数据库提取与状态、月份和年份相关的正确信息。当我单击提交按钮时,没有任何反应,我也没有在屏幕上收到任何错误。
我将不胜感激您能给我的任何建议和/或可能包含我需要的信息的网站。如果我应该以其他方式做,请告诉我。
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('members/connectvars.php');
// Connect to the database
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$dbc) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
if($_POST)
{
$state = $_POST['state'];
$month = $_POST['month'];
$year = $_POST['year'];
$query = mysql_query("SELECT * FROM triathlons WHERE state = '".$state."' month ='".$month."' year = '".$year."' ") or die(mysql_error());
$num = mysql_num_rows($query);
echo "$num results found!<br>";
while($result = mysql_fetch_assoc($query))
{
$day = $result['day'];
$date = $result['date'];
$city= $result['city'];
$racename= $result['racename'];
$park= $result['park'];
$website= $result['website'];
echo "<b> day</b> : $day<br>
<b>Last Name : </b> $date<br>
<b>city : </b>$city<br>
<b>state : </b>$state <br><br>";
}
}
}
?>
<form method="POST" id="filtermainpage" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="state">State:</label>
<select name="state" id="state1">
<option selected="selected" value="">All States</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DC">D.C.</option>
<option value="DE">Delaware</option>
<option value="FL" >Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</p>
<br
<br
<label for="month">Month:</label>
<select name="month" id="month1">
<option selected="selected" value="0">All Months</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<label for="year">Year:</label>
<select name="year" id="year1">
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>
</label>
</p>
<p>
<input type="submit" name="submit" id="button" value="submit">
</p>
</form>