Questions about smarty database query

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.