Any idea how to include variable in $row[] mysqli_query?
what I've tried until now:
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(*)'];
}
Also, I've tried all combination
echo $row[$var];
echo $row["$var"];
echo $row['$var'];
$varis not submitted by the user...$rowis what you have been doing in$row[$var]Variablesinstead and add an alias for the count, so you can use that as an index for$row.