我需要根据用户的第一个下拉选项填充下拉列表,但在我到达目前为止,我只是尝试使用预选的团队填充一个,以确保我首先获得该部分。但是使用这个代码,我得到了我的第一个团队名称下拉列表,但接下来是一个空文本字段,我似乎无法显示和填充第二个下拉列表。我是html和php的新手,我很确定我错过了一些简单的东西。非常感谢任何帮助,如果我能更清楚地了解我的问题,请告诉我。感谢。
<!DOCTYPE html>
<html>
<head><style>
</style></head>
<body>
<form>
<select name="teams">
<option value="Atlanta Hawks ">Atlanta Hawks</option>
<option value="Boston Celtics ">Boston Celtics</option>
<option value="Charlotte Bobcats ">Charlotte Bobcats</option>
<option value="Chicago Bulls ">Chicago Bulls</option>
<option value="Cleveland Cavaliers ">Cleveland Cavaliers</option>
<option value="Dallas Mavericks ">Dallas Mavericks</option>
<option value="Denver Nuggets">Denver Nuggets</option>
<option value="Detroit Pistons ">Detroit Pistons</option>
<option value="Golden State Warriors">Golden State Warriors</option>
<option value="Houston Rockets ">Houston Rockets </option>
<option value="Indiana Pacers ">Indiana Pacers </option>
<option value="LA Clippers ">LA Clippers</option>
<option value="LA Lakers ">LA Lakers</option>
<option value="Memphis Grizzlies ">Memphis Grizzlies</option>
<option value="Miami Heat">Miami Heat</option>
<option value="Milwaukee Bucks ">Milwaukee Bucks</option>
<option value="Minnesota Timberwolves ">Minnesota Timberwolves</option>
<option value="New Jersey Nets">New Jersey Nets</option>
<option value="New Orleans Hornets ">New Orleans Hornets</option>
<option value="New York Knicks ">New York Knicks</option>
<option value="Oklahoma City Thunder ">Oklahoma City Thunder</option>
<option value="Orlando Magic ">Orlando Magic</option>
<option value="Philadelphia Sixers ">Philadelphia Sixers </option>
<option value="Phoenix Suns ">Phoenix Suns</option>
<option value="Portland Trail Blazers ">Portland Trail Blazers</option>
<option value="Sacramento Kings ">Sacramento Kings</option>
<option value="San Antonio Spurs ">San Antonio Spurs</option>
<option value="Toronto Raptors ">Toronto Raptors</option>
<option value="Utah Jazz">Utah Jazz</option>
<option value="Washington Wizards ">Washington Wizards</option>
</select>
<input type="text" name="team">
<?php
$con=mysqli_connect("localhost","nbastakm_josh","ateam","nbastakm_Stats");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT fname, lname FROM PlayerRegSeason WHERE team='NYK' and year='2009'";
$result = mysqli_query($con,$sql);
if (!$result) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
$playermenu = "
<p><label>Players</label></p>
<select name='players' id='players'>";
while($row=mysqli_fetch_array($result)){
$playermenu = "<option>".$row['lname']."</option>";
}
$playermenu = "</select>";
echo $playermenu;
mysqli_close($con);
?>
</form>
</body>
</html>
答案 0 :(得分:0)
使用点来连接字符串:
while($row=mysqli_fetch_array($result)){
$playermenu .= "<option>".$row['lname']."</option>";
}
$playermenu .= "</select>";
答案 1 :(得分:0)
无法重新发送到服务器,无法使用客户端选项。你需要: