I have this example of foreach with array, and what I need to know is how can I enter mysql query to this array?
<?php
$cabecera=array("nombre","telefono","referencia");
$luis=array("Luis García","645395715","Trabajo");
$paco=array("Paco Salvatierra","625781225","Amigo");
$sofia=array("Sofía López","664887221","cliente");
$pilar=array("Pilar Martinez","674458115","familia");
$agenda=array($cabecera,$luis,$paco,$sofia,$pilar);
?>
First write the secondary arrays, which will form the rows of the table, and then insert them as elements of the main array. Then we show them nesting two foreach loops, using the necessary html code, we show them in a table:
<table border="1" width="60%" cellspacing="0">
<?php
foreach ($agenda as $fila){
echo "<tr>";
foreach ($fila as $celda){
echo "<td> $celda </td>";
}
echo "</tr>";
}
?>
include("conexiones.php");
//la variable $link esta en conexiones es la conexion a la base de datos
$cabecera = array($link,'SELECT fecha FROM clase');
$datos=array($link, 'select * from alumno ');
$agenda=array($cabecera,$datos);
?>
<table border="1" width="60%" cellspacing="0">
<?php
foreach ($agenda as $fila){
echo "<tr>";
foreach ($fila as $celda){
echo "<td> ".$celda." </td>";
}
echo "</tr>";
}
I get an error:
Catchable fatal error: Object of class mysqli could not be converted to string in C: \ xampp \ htdocs \ notebooks \ assas_areas.php on line 178