The error is simple, the query currently only returns one column, but you try to access a second column
echo $row[0].'<br>'; // correcto
echo $row[1].'<br>'; //incorrecto, indice no válido
Also, outside of while
it would not make sense to access $row
, the last two lines you must delete them.
Final Code
include("conexion.php");
$query4= mysqli_query($conexion,"SELECT refprofesor FROM asigna_materia
WHERE refgrupo='3-A' AND refcarrera='09TICSI'");
while($row = mysqli_fetch_array($query4, MYSQLI_NUM))
{
echo $row[0].'<br>';
}
It would not be convenient to have variables within while
since with a query, we will not know exactly how many records will return, it will work as long as a single record is obtained (it would not need a while) .
For this, a array
would be appropriate if you want to obtain the result and not print it directly.
$resultado = [];
while($row = mysqli_fetch_array($query4, MYSQLI_NUM))
{
$resultado[] = $row;
}
// Al terminar el while
//Aquí su variable $resultado, tendrá todos los registros devueltos