esta es la función que tengo en CRUD
Código PHP:
public function getArticulos() {
try {
$query = $this->dbh->prepare('SELECT articulos2.marca, articulos2.modelo, articulos2.garantia, articulos2.stock, departamentos.nom_dept FROM articulos2 INNER JOIN departamentos ON articulos2.dept=departamentos.id_dept WHERE departamentos.estado="s"');
$query->execute();
return $query->fetchAll();
$this->dbh = null;
}
catch(PDOException $e) {
$e->getMessage();
}
}
Código PHP:
foreach($articulos as $articulo){
<tr class="rows">
<td><?php echo $articulo["serial"]?></td>
<td><?php echo $articulo["marca"]?></td>
<td><?php echo $articulo["modelo"]?></td>
<td><?php echo $articulo["garantia"]?></td>
<td><?php echo $articulo["stock"]?></td>
<td><?php echo $articulo["nom_dept"]?></td>
<td width="80">
<a href="#" class="linkedit btn btn-success" id="mEdit">Editar</a>
</td>
<td width="80">
<a href="#" class="linkdelete btn btn-danger" id="mDelete">Eliminar</a>
</td>
</tr>
}
Código PHP:
echo "<pre>";
print_r($articulos);
echo "</pre>";
Código:
en mi caso tengo 7 registros y como tal imprime el código anterior 7 veces ya he buscado varias soluciones en Internet y nada de lo que he probado me funciona y me tiene desconcertado a ver si alguien me puede dar una luz al respecto de antemano agradezco su colaboración.. Array ( [0] => Array ( [serial] => 006 [0] => 006 [marca] => Toshiba [1] => Toshiba [modelo] => Portatil de 14 pulgadas [2] => Portatil de 14 pulgadas [garantia] => 12 meses [3] => 12 meses [stock] => 101 [4] => 101 [dept] => 1 [5] => 1 ) [1] => Array ( [serial] => 12 [0] => 12 [marca] => lenovo [1] => lenovo [modelo] => tableta [2] => tableta [garantia] => 13 meses [3] => 13 meses [stock] => 444 [4] => 444 [dept] => 1 [5] => 1 ) [2] => Array ( [serial] => 2014 [0] => 2014 [marca] => touch [1] => touch [modelo] => tableta [2] => tableta [garantia] => 15 meses [3] => 15 meses [stock] => 55 [4] => 55 [dept] => 1 [5] => 1 ) [3] => Array ( [serial] => 2030 [0] => 2030 [marca] => hp [1] => hp [modelo] => portatil locosss [2] => portatil locosss [garantia] => 12 meses [3] => 12 meses [stock] => 7 [4] => 7 [dept] => 2 [5] => 2 ) [4] => Array ( [serial] => 90 [0] => 90 [marca] => hp [1] => hp [modelo] => portatil loco [2] => portatil loco [garantia] => 12 meses [3] => 12 meses [stock] => 6 [4] => 6 [dept] => 1 [5] => 1 ) )