connect()->prepare($sql);
$stmt->execute();
while($row = $stmt->fetch()) {
echo '
';
echo '
'.substr($row['title'], 0, 100).'...
';
echo '
'.$this->getSource($row['source_id']).'
';
echo '
';
}
}
public function getSource($id) {
$sql = "SELECT * FROM sources WHERE id = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$id]);
$row = $stmt->fetch();
if($row['name'] == null) return 'No source';
else return $row['name'];
}
}
$generateObj = new generateTrendingNews();
$generateObj->generate();
?>