return a sequence of records from a function
Posted: Tue Mar 11, 2003 8:29 pm
if I want to write a function with a given Main_cat_id parameter and it will return its sub_cat_id, total num of topic, moderator...how can I return a list of records in the function....i wrote the function and it only gave the last record:
function chooseCAT($catID){
$db = getDBPConn();
$sql = "select cat_id, parent_cat_id, cat_name, priority, tot_topics, moderator, banner_code, rec_cr_date, last_upd_date
from game_forum_category where parent_cat_id=$catID order by priority";
$result = $db->query($sql);
if (DB::isError($result = $db->query($sql))){
die (DB::errorMessage($result));
}
if ($result->numRows() > 0){
while ($row = $result->fetchRow()) {
$cat_id = $row[0];
$parent_cat_id = $row[1];
$cat_name = $row[2];
$priority = $row[3];
$tot_topics = $row[4];
$moderator = $row[5];
$banner_code = $row[6];
$rec_cr_date = $row[7];
$last_upd_date = $row[8];
return array($cat_id, $parent_cat_id, $cat_name, $priority, $tot_topics, $moderator, $banner_code, $rec_cr_date, last_upd_date);
}
} else {
return false;
exit;
}
$result->free();
$db->disconnect();
}
function chooseCAT($catID){
$db = getDBPConn();
$sql = "select cat_id, parent_cat_id, cat_name, priority, tot_topics, moderator, banner_code, rec_cr_date, last_upd_date
from game_forum_category where parent_cat_id=$catID order by priority";
$result = $db->query($sql);
if (DB::isError($result = $db->query($sql))){
die (DB::errorMessage($result));
}
if ($result->numRows() > 0){
while ($row = $result->fetchRow()) {
$cat_id = $row[0];
$parent_cat_id = $row[1];
$cat_name = $row[2];
$priority = $row[3];
$tot_topics = $row[4];
$moderator = $row[5];
$banner_code = $row[6];
$rec_cr_date = $row[7];
$last_upd_date = $row[8];
return array($cat_id, $parent_cat_id, $cat_name, $priority, $tot_topics, $moderator, $banner_code, $rec_cr_date, last_upd_date);
}
} else {
return false;
exit;
}
$result->free();
$db->disconnect();
}