Smarty database query problem functionclass_id () {if (! Empty ($ _ GET [class_id]) {$ SQL & quot; select * fromgoods_classasa, goods_detailasbwherea. $ _ GET [class_id] & quot; smarty database query problem
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 statements can be normally displayed in html after they are put out of the method, but cannot be written like this. why?
------ Solution --------------------
$ Sm_class = class_id ();
$ Smarty-> assign ("sm_class", $ sm_class );