I use Smarty's different ways, the specific method, etc.

xiaoxiao2021-03-06  41

* .tpl

{* assign var = "BottomtiTlenum" value = "2" *} {* section name = bst loop = $ bottomshortcuttitle *} {* if ($ smarty.section.bst.index mod $ bottomtiTenum) EQ 0 *} {* / if *}
{** Title * *} {* $ BOTTOMSHORTCUTTITETITETETETER [BST] .bsctName *}
{** Title End **} {** SUB B Start **}

Cellpadding = "0" cellspacing = "0"> {* assign var = "bottomcontentnum" value = "3" *} {** content loop **} {* section name = BSC loop = $ bottomshortcutcontent [bst] *} { * IF ($ smarty.section.bsc.index mod $ bottomcontentnum) EQ 0 *}

{* / if *}
{* $ bottomshortcutcontent [bst] [bsc] .bscname *} {* if ($ smarty.section.bsc. Index Mod $ BOTTOMCONTENTNUM) EQ ($ bottomcontentnum-1) *} {* / if *} {* / section *} {** SUB End **} {* IF ( $ smarty.section.bst.index mod $ bottomtitlenum) EQ ($ bottomtiTlenum-1) *} {* / if *} {* / section *} * .php

// Native database related data $ dbrserver = 'localhost'; $ dbuser = 'root'; $ dbname = 'ccst'; $ dbpasswd = 'zzzzz'; // Establish a Smarty instance object $ smarty

$ smarty = new smarty (); $ smarty-> template_dir = "./ Templates / Default"; $ smarty-> compile_check = true; $ smarty-> left_delimiter = "{*"; $ smarty-> right_delimiter = "*} "

// Establish Oakdb object $ dbh to query the database, give a given four parameters automatically connected database

// connect the database $ dbh_title = new OakDB ($ DBServer, $ DBUser, $ DBPasswd, $ DBName); // query leftshortcuttitle, return titles $ querytext_title = 'SELECT * FROM bottomshortcuttitle'; $ dbrs_title = $ dbh_title-> queryDB ( $ querytext_title); while ($ asgnrs_title = mysql_fetch_array ($ dbrs_title)) {$ value_title [] = $ asgnrs_title; // connect the database $ dbh_content = new OakDB ($ DBServer, $ DBUser, $ dBPasswd, $ DBName); $ querytext_content = 'Select * from bottomShortcut where bsctitle = /' '. $ Asgnrs_title [' bsctname '].' / '; $ Dbrs_content = $ dbh_content-> querydb ($ querytext_content); // row pointer DBRS // put the database content the value $ [] array while ($ asgnrs_content = mysql_fetch_assoc ($ dbrs_content)) {$ value_temp [] = $ asgnrs_content; echo 1;} $ value_content [] = $ value_temp;} $ smarty-> assign ( 'bottomshortcuttitle', $ value_title); // Template variable replacement content Put $ smarty-> assign ('bottomshircutcontent', $ value_content);

// Compile and display the navigation.tpl template under ./Templates

$ Smarty-> Display ('bt.tpl');

?>

转载请注明原文地址:https://www.9cbs.com/read-78907.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.031, SQL: 9