I want to pass a mySQL result from a function and print the data.
How to do so ?
<?php
function showLatestItems()
{
$result = $this->query("SELECT aid,name,description,img,amount,strtdate,enddate FROM item WHERE enddate>now()");
return $result;
/* while($row=mysql_fetch_array($result))
echo $row[0].' '.$row[3].' '.$row[1].' '.$row[2].$row[4].$row[5].$row[6].'<br>';
*/
}
?>
Just trap the result resource and then fetch rows from it. Based on the commented out code, we assume you have wrapped
mysql_query()with a class method calledquery().