请大虾们帮忙改看下这段代码为什么不能得到二维数组????
帮忙看一下这段代码能不能得到三维数组???
$top_news
//--------------------------------------------头条新闻-----------------------------------------
$sql="select * from auto_news where seat_name='新闻头条' ";
$rs = $db -> SelectLimit($sql,3,0);
if($rs === false)
{
print $db->ErrorMsg();
}else{
while(!$rs->EOF)
{
$top_news[] ="<h3><a href=\"http://www.sinajn.com\"><FONT
color=#bc2931>".$rs->fields['big_title']."</FONT></a> </h3>";
$sql_about = "select * from auto_news where connect_id=".$rs->fields['id'];
$rs_about = $db -> SelectLimit($sql_about,3,0);
/ smarty -> assign("top_news",$top_news);
if($rs_about === false)
{
print $db->ErrorMsg();
}else{
while(!$rs_about->EOF)
{
$top_news[][] ="[<A href=\"http://www.sinajn.com\">".$rs_about->fields['big_title']."</A>]";
$rs_about->MoveNext();
}
}
$rs->MoveNext();
}
}
帮忙看一下这段代码能不能得到三维数组???
$top_news
//--------------------------------------------头条新闻-----------------------------------------
$sql="select * from auto_news where seat_name='新闻头条' ";
$rs = $db -> SelectLimit($sql,3,0);
if($rs === false)
{
print $db->ErrorMsg();
}else{
while(!$rs->EOF)
{
$top_news[] ="<h3><a href=\"http://www.sinajn.com\"><FONT
color=#bc2931>".$rs->fields['big_title']."</FONT></a> </h3>";
$sql_about = "select * from auto_news where connect_id=".$rs->fields['id'];
$rs_about = $db -> SelectLimit($sql_about,3,0);
/ smarty -> assign("top_news",$top_news);
if($rs_about === false)
{
print $db->ErrorMsg();
}else{
while(!$rs_about->EOF)
{
$top_news[][] ="[<A href=\"http://www.sinajn.com\">".$rs_about->fields['big_title']."</A>]";
$rs_about->MoveNext();
}
}
$rs->MoveNext();
}
}
你在循环的时候又重新对QUERYSOURCE进行修改,所以不能正确的循环
解决办法可以有一:把第一次$rs->fields['id'];存成数组,第二次用数组循环
二:重新实例化一个对象,循环里面用另一个DB对象操作