So as the title says i'm having an issue when trying to display the 5 results from my sql query i don't know how to convert them to an array,
# Collection of SQL
try {
$sql = $conn->query("SELECT Channel_Location FROM channels
ORDER BY RAND()
Limit 5");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
foreach($sql->fetchAll(PDO::FETCH_ASSOC) as $c) {
echo $c . "<br>";
}
$conn = null;
I can't work out how to display the results, it displays one result if i change foreach($sql->fetchAll(PDO::FETCH_ASSOC) as $c) {
to foreach($sql->fetch(PDO::FETCH_ASSOC) as $c) {
but i need it to display each result