I'm trying to get an echo of the column names (except the first column) of a table from my database. I used the code below. In my div I get the echo "Cannot get xValues". So it seems that my query doesn't work from the very start. Note however that it was my first time using multi_query(), so maybe I'm missing something. FYI, if I use msqli_query() (and remove the if statement) and I try to echo all the column names of my table without going through the creation of a temporary table to remove the first column, the code works just fine. I appreciate your assistance on this matter. Thanks
$query = "CREATE TEMPORARY TABLE temp_tb SELECT * FROM $tableName";
$query .= "ALTER TABLE temp_tb DROP col1";
$query .= "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$dbName' AND TABLE_NAME = 'temp_tb'";
if ($mysqli -> multi_query($query)){
while($row = $query->fetch_assoc()){
$result1[] = $row;
}
$columnArr = array_column($result1, 'COLUMN_NAME');
foreach($columnArr as $columnNames){
$xValues = "'".$columnNames."'".",";
echo $xValues;
}
} else{
echo "Cannot get xValues";
}