This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center。
7年前关闭。
我想要做的是在while循环中有一个单选按钮,每次运行循环时,无线电的名称都要增加1。
目前,该代码无法正常工作,因为它没有逐步增加。任何建议都很好。
..并将
7年前关闭。
我想要做的是在while循环中有一个单选按钮,每次运行循环时,无线电的名称都要增加1。
目前,该代码无法正常工作,因为它没有逐步增加。任何建议都很好。
$query = mysql_query("SELECT * FROM table WHERE id = '1' ORDER BY time ASC");
echo '<table> <th> A </th> <th> time </th> <th> B </th>';
while($row = mysql_fetch_assoc($query)) {
$i= 1;
echo '<tr><td>';
echo '<input type="radio" name="';echo $i++; echo'" /> '; echo $row['a'];
echo '</td>';
echo '<td>';
echo $row['time'];
echo '</td>';
echo '<td>';
echo '<input type="radio" name="';echo $i++; echo '" />'; echo $row['b'];
echo '</td> </tr> ';
}
echo '</tr></table>';
最佳答案
您每次都要重置计数器。
$i = 1;
while($row = mysql_fetch_assoc($query)) {
// Your code
$i++;
}
..并将
echo $i++;
替换为echo $i;
。关于php - php while循环与$ i++ ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15748840/
10-17 02:42