After fetching the rows, you attempt to set variables directly from
$rows
, for example
$name = $rows['threadName'];
. But that won't work because
'threadName'
is only a valid index when you use it
on one row, not on the collection of rows. So, you have to fetch these variables inside your foreach (from
$row
), not outside the foreach:
echo "<table class=\"discussion\">\n";
echo "<tr><th colspan=2>Thread Name<<th>Replies</th><table><thead><th>Author</th></thead></table></tr>\n";
$rows = $output -> fetchAll();
foreach ($rows as $row){
$name = $row['threadName'];
$body = $row['threadBody'];
$by = $row['threadBy'];
$date = $row['dateCreated'];
$sticky = $row['threadSticky'];
$image = '<img src="images/userIcon.gif">';
echo "<tr>";
echo"<td>".$image."</td>";
echo"<td>".$name."<br>".$body."</td>";
}
echo "</tr>\n";
echo "</table>";