>  기사  >  백엔드 개발  >  smarty 数据库查询有关问题

smarty 数据库查询有关问题

WBOY
WBOY원래의
2016-06-13 13:53:33749검색

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으로 문의하세요.