php - 使用数据库中的多行自动递增循环
问题描述
我有一个 mysql 查询,它从数据库中提取一个变量并根据变量的数量重复一些 html。然后它根据自动增量为单选按钮分配一个 ID。
当查询只返回一行时,这工作正常,但是当返回 2 行时,它会将 ID 0 分配给 2 批单选按钮,然后分配 1、2、3 等
<?php
$roster_infantry_raw = tep_db_query("select * from " . $table . " where name = '" . $_GET['model'] . "'");
while ($infantry = tep_db_fetch_array($roster_infantry_raw)) {
for ($i = 0; $i < (int) $infantry['count_min']; $i++) {
?>
<table class="table table-striped table-hover">
<tr>
<td scope="row">
<?php echo tep_draw_radio_field('weapon1[' . $i . ']', 'weapon1', true); ?></td>
</tr>
</table>
<?php
}
}?>
解决方案
推荐阅读
- postgresql - 基本上我有三个带有链接的表,并试图在一个表中获得结果
- html - 如何通过powershell从HTML文件中删除一列
- javascript - 将“this”引用到数组
- sql - 使用相关筛选筛选 SQL Server 数据
- azure - 如何在 Azure API 管理策略中读取 SOAP 消息并创建变量
- javascript - 警告:React.createElement:类型无效——需要一个字符串或一个类/函数,但得到:未定义
- python - 如何随机更改数组的索引?
- vue.js - vue router-link 是否有(标准)方法可以使用不同的键或数据刷新相同的路由?
- jmeter - 是否可以在 Fiddler 工具中捕获 NeoLoad 脚本重播?
- r - 尝试使用 tidyverse 库时出错