Tuesday, December 19, 2006

Smarty的section镶套

数组

Array ( [0] => Array ( [HelpClassName] => 常见问题 [HelpClassID] => 1
[Help] => Array ( [0] => Array ( [HelpSubjectName] => PERL! [HelpSubjectID] => 1 ) [1] => Array ( [HelpSubjectName] => PYTHON[HelpSubjectID] => 4 )[2] => Array ( [HelpSubjectName] => RUBY? [HelpSubjectID] => 14 ) ) )

[1] => Array ( [HelpClassName] => 关于概念 [HelpClassID] => 3 [Help] => Array ( [0] => Array ( [HelpSubjectName] => 到底什么是PHP [HelpSubjectID] => 6 ) [1] => Array ( [HelpSubjectName] => php与PYTHON的区别是什么? [HelpSubjectID] => 7 ) ) )


[2] => Array ( [HelpClassName] => 新人必读 [HelpClassID] => 4 [Help] => Array ( [0] => Array ( [HelpSubjectName] => 怎样在PHP? [HelpSubjectID] => 13 ) [1] => Array ( [HelpSubjectName] => PHP使用说明(一) [HelpSubjectID] => 15 ) [2] => Array ( [HelpSubjectName] => PYTHON使用说明(二) [HelpSubjectID] => 16 ) [3] => Array ( [HelpSubjectName] => 如何PHP? [HelpSubjectID] => 17 ) [4] => Array ( [HelpSubjectName] => RUBY(三) [HelpSubjectID] => 18 ) ) ) );

?>


smarty,section镶套














function displayClass(){
global $help;
$helpClassSQL = "SELECT * FROM ".$this->Table['Class']." ORDER BY HelpClassID";
$this->DBase->Query($ClassSQL);
$helpClassNum = $this->DBase->NumRows();
for($i=0; $i < $helpClassNum; $i++){
$this->DBase->NextRecord();
$help[$i]['HelpClassName'] = $this->DBase->Record['HelpClassName'];
$help[$i]['HelpClassID'] = $this->DBase->Record['HelpClassID'];
$this->ClassName[$this->DBase->Record['HelpClassID']]=$this->DBase->Record['HelpClassName'];
}
return $help;
}

function displayMyClassList(){
global $help;
$this->displayHelpClass();
for($i=0;$iClassName);$i++){
$classID = key($this->ClassName);
$className = $this->ClassName[$classID];
$help['HelpClass'][$i]['HelpClassName'] = $className;
$help['HelpClass'][$i]['HelpClassID'] = $classID;

$helpSQL = "SELECT * FROM ".$this->Table['HelpSubject']." WHERE HelpClassID='".$classID."' ORDER BY HelpSubjectID ASC";
$this->DBase->Query($helpSQL);
echo $this->DBase->Error;
$helpNum = $this->DBase->NumRows();
for($j=0; $j < $helpNum; $j++){
$this->DBase->NextRecord();
$help['HelpClass'][$i]['Help'][$j]['HelpSubjectName'] = $this->DBase->Record['HelpSubjectName'];
$help['HelpClass'][$i]['Help'][$j]['HelpSubjectID'] = $this->DBase->Record['HelpSubjectID'];
}
next($this->ClassName);
}
// print_r($help['HelpClass']);exit;
$help = $help['HelpClass'];
return $help;
}

No comments:

Post a Comment