I store some data from the MySQL database into an array:
$p = $db->query('SELECT * FROM comments;');
while ($row = $p->fetch(PDO::FETCH_ASSOC)) {
$commentlist[$row['id']] = $row['text'];
}
foreach($commentlist as $key => $value) {
echo $key;
echo $value;
}
Now I have access to the values id
and text
. But I also need to have access to the value image
(which is another row in the MySQL database). But how can I store it if I have only two available elements: key and value?