I'm making a timeline-alike widget but I'm stuck at the fetchAll()
function.
<?php
require('./dbconfig.php');
$userid = $_SESSION['user_session'];
$query = $DB_con->prepare("SELECT bericht FROM tijdlijn WHERE auteurid=:uid");
$query->execute(array(':uid' => $userid));
$tijdlijn=$query->fetchAll(PDO::FETCH_ASSOC);
print_r ($tijdlijn[1]);
?>
which results in this:
Array ( [bericht] => Dit is een 2de test )
I just want 'Dit is een 2de test' to show up, not all the other stuff.
I also want to show all the messages that are from the same author. I have a script that only shows the messages to the author.
The array is 2-dimensional, you also need to specify the second index or it will print the entire second dimension.
print_r ($tijdlijn[1]['bericht']);
The array it's first index is the row # of the output and the second index is the column name.