I want to be able to have control of what I print in this array. So far this is what I have:
<?php
/* DB CONNECTION */
try {
$pdo = new PDO('mysql:host=' . DB_HOST . '; dbname=' . DB_NAME . '', DB_USER, DB_PASSWORD);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
$sql = 'SELECT nombre,categoria,descripcion FROM equipos ORDER BY nombre ASC';
$result = $pdo->query($sql);
}
catch(PDOException $e) {
echo $error = 'Error fetching jokes: ' . $e->getMessage();
exit();
}
/*FETCH ARRAY */
$equipos = array();
while ($row = $result->fetch()) {
$equipos[] = $row['nombre'];
$equipos[] = $row['categoria'];
$equipos[] = $row['descripcion'];
}
?>
<?php
/* PRINT ARRAY */
foreach($equipos as $equipo): ?>
<p><?php
echo htmlspecialchars($equipo);
?></p>
<?php
endforeach;
?>
My results are:
Value1
value2
Value3
etc.
I want to be able to print something like:
Value1, Value2, Value3
Value4, Value5, Value6
There's must be a practical easier way.