我建立了这个页面:http://excelwrestling.com/poola.php即将到来的双重锦标赛。我的大部分数据都是从我的 mySQL 数据库中提取的,现在只有一些示例数据。
我希望链接选择框,因此当用户选择 TEAM 1(在顶部)时,它将更新所有 WRESTLER 1 选择框,仅包含该团队的名称。第 2 队也是如此。
另一部分是,当一个人选择 WRESTLER 1 与 WRESTLER 2 时,我希望这两个名字填写 WINNER 字段,因此用户只能在这两个名字之间进行选择。
如果您能向我解释或发布代码,我们将不胜感激。
谢谢!
最佳答案
您可能想使用特殊查询从团队中获取摔跤手。然后使用 while 循环从数组中更新团队中的所有摔跤手。然后将数组分配给从数据库中选择的特殊索引号。你能显示数据库中的内容吗?我需要知道才能提供帮助。因为我不知道你的数据库里有什么。我只是猜测您的数据库是如何组织的。假设您的团队下拉列表名为 team_select,并且 wreSTLer 表中的每个 wreSTLer 都有一个 wreSTLer_id wreSTLer_name 和一个 team_id。
您将执行以下代码
$team_select = $_POST['team_select']
$wrestler_query = "SELECT wrestler_name FROM wrestler WHERE team_id = "
. $team_select;
$query = mysqli_query($connection, $wrestler_query);
//Repeat code from here... (see bottom)
while( $team_select = mysqli_fetch_assoc($query));
{
echo '<option class="Select1" value="' . $team_select['wrestler_name'] . '">'</option>
}
<?
</select>
<?php
mysqli_data_seek($accounts,0);
//..to here for other drop down lists (except give the different names of different drop down lists in the html.)
另外不要忘记,连接变量是数据库访问凭据。
关于php - 链式选择框 - 基本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11251175/