我正在尝试获取在$sql = "";
中选择的每一行的结果
但是我没有成功。尝试了不同的代码,但没有一个起作用。这是我的代码:
$sql2 = "SELECT player1, player2, player3, player4, player5, player6, player7, player8, player9, player10, player11, player12, player13, player14, player15, player16, player17, player18, player19, player20, player21, player22, player23, player24 FROM `savedpacks` WHERE `packid`=" . $_GET['id'] . "";
$result2 = $conn->query($sql2);
while( $row2 = mysqli_fetch_assoc( $result2)) {
$sql = "SELECT * FROM `players_db` WHERE `id`=" . $row2['player1'] . "";
$result = $conn->query($sql);
$row = mysqli_fetch_assoc( $result);
if ($row['Revision'] != 0) {`
我正在尝试获取每个选定行的结果,因此是player1,player2等。但是如您所见,我设法只获得了player1的行。我希望有人能帮助我。谢谢!
最佳答案
像这样在while循环中使用for循环
$sql2 = "SELECT player1, player2, player3, player4, player5, player6, player7, player8, player9, player10, player11, player12, player13, player14, player15, player16, player17, player18, player19, player20, player21, player22, player23, player24 FROM `savedpacks` WHERE `packid`=" . $_GET['id'] . "";
$result2 = $conn->query($sql2);
while( $row2 = mysqli_fetch_assoc( $result2)) {
for($i=1;$i<=24;$i++)
{
$sql = "SELECT * FROM `players_db` WHERE `id`=" . $row2['player'.$i] . "";
$result = $conn->query($sql);
$row = mysqli_fetch_assoc( $result);
if ($row['Revision'] != 0) {`...}
}