gpt4 book ai didi

$row[] 中的 PHP 变量

转载 作者:搜寻专家 更新时间:2023-10-31 20:58:32 26 4
gpt4 key购买 nike

知道如何在 $row[] mysqli_query 中包含变量吗?

到目前为止我尝试过的:

1

$result = mysqli_query($connection, "SELECT ".$var." AS Variables, COUNT(*)  FROM data GROUP BY '$var'"); 
while($row = mysqli_fetch_array($result)) {
echo $row['Variables'];
echo $row['COUNT(*)'];
}

2

$result = mysqli_query($connection, "SELECT '$var', COUNT(*)  FROM data GROUP BY '$var'"); 
while($row = mysqli_fetch_array($result)) {
echo $row[$var];
echo $row['COUNT(*)'];
}

此外,我已经尝试了所有组合

echo $row[$var];
echo $row["$var"];
echo $row['$var'];

最佳答案

试试这个:

$result = mysqli_query($connection, "SELECT ".$var." AS Variables, 
COUNT(*) AS count FROM data GROUP BY '$var'");
while($row = mysqli_fetch_array($result)) {
echo $row['Variables'];
echo $row['count'];
}

关于$row[] 中的 PHP 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49631865/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com