[英]Issues with array
我有一個這樣的輸入列表......
藍色區域是列出用戶名的地方。 輸入字段用於添加玩家。 每個用戶共有 13 名玩家。 我很難弄清楚如何INSERT
特定播放器並將其分配給該用戶。 有人告訴我我可以用數組來做到這一點。
我一直在與數組作斗爭,但不知道如何做到這一點。 我創建它是為了嘗試,但不知道下一步該怎么做,或者這是否正確。
<?php
$playerArray = array();
while($row = mysqli_fetch_array($stmt)) {
$playerArray[] = $row['player_name'];
}
?>
<input class="draftBorder" value='<?php echo $player1; ?>'/>
<input name="$playerArray[]" "class="draftBorder" value='<?php echo $player2; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player3; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player4; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player5; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player6; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player7; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player8; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player9; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player10; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player11; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player12; ?>'/>
<input name="$playerArray[]" class="draftBorder" value='<?php echo $player13; ?>'/>
我是否以正確的方式處理數組? 我如何將它INSERT
到與玩家輸入的用戶相關聯的數組中?
我想你不明白如何使用數組。 這對你有幫助嗎?
$i = 1;
while($row = mysqli_fetch_array($stmt)) {
$playerArray = $row['player_name'];
$valueInput = $player."".$i;
echo "<input name='$playerArray' 'class='draftBorder' value='$valueInput'/>";
$i++;
}
對於查詢中的所有玩家,您將有一個輸入,其值將是 $player1、$player2 等。
我認為您希望它們是text
類型。 你最好輸入你的輸入
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.