Returning info from a function
Posted: Fri Dec 02, 2005 12:49 pm
I have written the following function to retrieve info from a database and now need to display it. Until now I have used echo within the function but am now trying to remove that from it.
Firstly is this the correct way of doing this and secondly how do I call the function on another page and display the results.
Firstly is this the correct way of doing this and secondly how do I call the function on another page and display the results.
Code: Select all
function recentsubs() {
global $database;
$sql = "SELECT
skinz_cats.cat_id , skinz_cats.cat_name,
skinz_images.subs_name, skinz_images.subs_id, skinz_images.subs_downloads
FROM
skinz_cats
LEFT JOIN
skinz_images
ON
skinz_images.cat_id = skinz_cats.cat_id
WHERE
skinz_images.status = '1'
ORDER BY
subs_date
DESC LIMIT 10";
$result = $database->sql_query($sql);
while($row = mysql_fetch_assoc($result)) {
$recsub[] = $row;
}
return $recsub;
}