首頁 >後端開發 >php教程 > smarty 数据库查询有关问题

smarty 数据库查询有关问题

WBOY
WBOY原創
2016-06-13 13:53:33798瀏覽

smarty 数据库查询问题
function class_id(){
if(!empty($_GET['class_id'])){
$sql="select * from goods_class as a,goods_detail as b where a.id=b.class_id and a.id='$_GET[class_id]'";
$query=mysql_query($sql);
while($row_class=mysql_fetch_array($query)){
$sm_class[]=array("name"=>$row_class['goods_name'],"id"=>$row_class['id'],"picture"=>$row_class['picture']);

  }
}
return $sm_class;
//print_r($sm_class);
}

class_id();
$smarty->assign("sm_class",$sm_class);

if语句放到方法外可以再html中正常显示,上面这样写则不行,为什么?

------解决方案--------------------
$sm_class =class_id();
$smarty->assign("sm_class",$sm_class);

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn