Hi, I have this function which currently outputs the data but I would like the class calling this function to handle the output instead. How do I go about doing that?
Main class:
I want to be doing the echo part of the code in the main class instead so my comments function can be more generic.
Thanks, Kevin
Code:
function comments($number) {
$query = "SELECT id,title,comment FROM comment ORDER BY id DESC";
$result = @mysql_query($query) or die('No ID found');
$count = 0;
while (($row = mysql_fetch_assoc($result)) && ($count < $number)) {
echo $row['title'] . " ";
echo $row['comment'] . "<br/>";
$count++;
}
mysql_free_result($result);
}
Code:
<?php lastfive::comments(3); ?>
Thanks, Kevin
Comment