我正在使用 PHP 循环创建一些 HTML 表单元素。我有一个来自查询的变量,我用它来计算我需要多少元素。我需要做的是在每个循环中为表单分配不同的变量。这是我的代码:{
for ($x = 1; $x <= $WMATTND; ++$x)
{
echo "<tr>";
echo "<td>";
echo "<label>Please enter name for badge:</label>";
echo "<input style='HEIGHT: 22px WIDTH: 427px' size='21' name='nameBadge'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<label>";
echo "Select Title for badge: ";
echo "<select id='badgeTitle' name='badgeTitle'>";
echo "<option>Select Badge Title</option>";
echo "<option value='owner'>Owner</option>";
echo "<option value='manager'>Manager</option>";
echo "<option value='buyer'>Buyer</option>";
echo "<option value='guest'>Guest</option>";
echo "</select>";
echo "</label>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<p>";
echo "<label>";
echo "<input type='checkbox' name='saturdayBk' id='saturdayBk'>";
echo "Saturday Breakfast</label>";
echo "</p>";
echo "<p>";
echo "<label>";
echo "<input type='checkbox' name='saturdayLh' id='saturdayLh'>";
echo "Saturday Lunch</label>";
echo "</p>";
echo "<p>";
echo "<label>";
echo "<input type='checkbox' name='sundayBk' id='sundayBk'>";
echo "Sunday Breakfast</label>";
echo "</p>";
echo "</td>";
echo "</tr>";
}
?>
}
我需要的一个例子是取'nameBadge'并给它一个'nameBadgex $'变量,其中x$是当前循环号。