经测试代码如下:@H_404_2@
/**
* 递归函数
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function get_scat_url($temp_catid) {
static $url;
global $site_id=5;
if ($temp_catid != 0) {
$temp_sql=db_query("select sm_cat_id,sm_cat_pcat_id,sm_cat_url,sm_cat_parentid from sitemap_category where sm_cat_id ='". $temp_catid . "' and sm_domain_id ='". $site_id . "'");
if (db_num_rows($temp_sql) > 0) {
$rec_set = db_fetch_array($temp_sql);
$url = $rec_set['sm_cat_url']. " : " . $url;
$temp_catid = $rec_set['sm_cat_parentid'];
get_scat_url($temp_catid);
}
} //first if statement
return $url;
}
//incorrect recursive call in PHP program
function get_scat_url($temp_catid){
//global $url;
$site_id=5;
while($temp_catid != 0) {
$temp_sql=db_query("select sm_cat_id,sm_cat_parentid from sitemap_category where sm_cat_id ='". $temp_catid . "' and sm_domain_id ='". $site_id . "'");
if (db_num_rows($temp_sql) > 0){
$rec_set = db_fetch_array($temp_sql);
$url = $rec_set['sm_cat_url']. " : " . $url;
$temp_catid = $rec_set['sm_cat_parentid'];
get_scat_url($temp_catid);
}
} //while ends here...
return $url;
}
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528866.html