php代码如下:
//获取网站配置信息
$setting_mod = M('setting');
$setting = $setting_mod->select();
foreach ( $setting as $val ) {
$set[$val['name']] = stripslashes($val['data']);
}
$this->assign('set',$this->setting);
模板文件如下:{$set.site_title};为啥不能提出呢
THINKPHP中怎么提取这种数据表形式的数据显示在模板中?
答案:2 悬赏:50
解决时间 2021-02-16 21:43
- 提问者网友:冰点阿弟
- 2021-02-16 00:22
最佳答案
- 二级知识专家网友:荒唐后生
- 2021-02-16 01:25
foreach ( $setting as $val ) {
$set[$val['name']] = stripslashes($val['data']);
}
把这段代码给删掉
然后在模版页用volist循环输出
<table>
<tr>
<th>name</th>
<th>data</th>
</tr>
<volist name="set" id="vo">
<tr>
<td>{$vo.name}</td>
<td>{$vo.data}</td>
</tr>
</volist>
</table>
$set[$val['name']] = stripslashes($val['data']);
}
把这段代码给删掉
然后在模版页用volist循环输出
<table>
<tr>
<th>name</th>
<th>data</th>
</tr>
<volist name="set" id="vo">
<tr>
<td>{$vo.name}</td>
<td>{$vo.data}</td>
</tr>
</volist>
</table>
全部回答
- 1楼网友:你好陌生人
- 2021-02-16 01:58
if(!is_writable('config.php')){
emmsg('配置文件(config.php)不可写。如果您使用的是unix/linux主机,请修改该文件的权限为777。如果您使用的是windows主机,请联系管理员,将此文件设为可写');
}
if(!is_writable(emlog_root.'/content/cache')){
emmsg('缓存文件不可写。如果您使用的是unix/linux主机,请修改缓存目录 (content/cache) 下所有文件的权限为777。如果您使用的是windows主机,请联系管理员,将该目录下所有文件设为可写');
}
$config = "hashpassword($adminpw);
$dbcharset = 'utf8';
$type = 'myisam';
$table_charset_sql = $db->getmysqlversion() > '4.1' ? 'engine='.$type.' default charset='.$dbcharset.';' : 'engine='.$type.';';
if ($db->getmysqlversion() > '4.1' ){
$db->query("alter database `{$db_name}` default character set utf8 collate utf8_general_ci;", true);
}
$widgets = option::getwidgettitle();
$sider_wg = option::getdefwidget();
$widget_title = serialize($widgets);
$widgets = serialize($sider_wg);
define('blog_url', getblogurl());
$sql = "
drop table if exists {$db_prefix}blog;
create table {$db_prefix}blog (
gid int(10) unsigned not null auto_increment,
title varchar(255) not null default '',
date bigint(20) not null,
content longtext not null,
excerpt longtext not null,
alias varchar(200) not null default '',
author int(10) not null default '1',
sortid int(10) not null default '-1',
type varchar(20) not null default 'blog',
views int(10) unsigned not null default '0',
comnum int(10) unsigned not null default '0',
attnum int(10) unsigned not null default '0',
top enum('n','y') not null default 'n',
sortop enum('n','y') not null default 'n',
hide enum('n','y') not null default 'n',
checked enum('n','y') not null default 'y',
allow_remark enum('n','y') not null default 'y',
password varchar(255) not null default '',
template varchar(255) not null default '',
primary key (gid),
key date (date),
key author (author),
key sortid (sortid),
key type (type),
key views (views),
key comnum (comnum),
key hide (hide)
)".$table_charset_sql."
insert into {$db_prefix}blog (gid,title,date,content,excerpt,author,views,comnum,attnum,top,sortop,hide,allow_remark,password) values (1, '欢迎使用emlog', '".time()."', '恭喜您成功安装了emlog,这是系统自动生成的演示文章。编辑或者删除它,然后开始您的创作吧!', '', 1, 0, 0, 0, 'n', 'n', 'n', 'y', '');
drop table if exists {$db_prefix}attachment;
create table {$db_prefix}attachment (
aid int(10) unsigned not null auto_increment,
blogid int(10) unsigned not null default '0',
filename varchar(255) not null default '',
filesize int(10) not null default '0',
filepath varchar(255) not null default '',
addtime bigint(20) not null default '0',
width int(10) not null default '0',
height int(10) not null default '0',
mimetype varchar(40) not null default '',
thumfor int(10) not null default 0,
primary key (aid),
key blogid (blogid)
)".$table_charset_sql."
drop table if exists {$db_prefix}comment;
create table {$db_prefix}comment (
cid int(10) unsigned not null auto_increment,
gid int(10) unsigned not null default '0',
pid int(10) unsigned not null default '0',
date bigint(20) not null,
poster varchar(20) not null default '',
comment text not null,
mail varchar(60) not null default '',
url varchar(75) not null default '',
ip varchar(128) not null default '',
hide enum('n','y') not null default 'n',
primary key (cid),
key gid (gid),
key date (date),
key hide (hide)
)".$table_charset_sql."
drop table if exists {$db_prefix}options;
create table {$db_prefix}options (
option_id int( 11 ) unsigned not null auto_increment,
option_name varchar( 255 ) not null ,
option_value longtext not null ,
primary key (option_id),
key option_name (option_name)
)".$table_charset_sql."
insert into {$db_prefix}options (option_name, option_value) values ('blogname','点滴记忆');
insert into {$db_prefix}options (option_name, option_value) values ('bloginfo','使用emlog搭建的站点');
insert into {$db_prefix}options (option_name, option_value) values ('site_title','');
insert into {$db_prefix}options (option_name, option_value) values ('site_description','');
insert into {$db_prefix}options (option_name, option_value) values ('site_key','emlog');
insert into {$db_prefix}options (option_name, option_value) values ('log_title_style','0');
insert into {$db_prefix}options (option_name, option_value) values ('blogurl','".blog_url."');
insert into {$db_prefix}options (option_name, option_value) values ('icp','');
insert into {$db_prefix}options (option_name, option_value) values ('footer_info','');
insert into {$db_prefix}options (option_name, option_value) values ('admin_perpage_num','15');
insert into {$db_prefix}options (option_name, option_value) values ('rss_output_num','0');
insert into {$db_prefix}options (option_name, option_value) values ('rss_output_fulltext','y');
insert into {$db_prefix}options (option_name, option_value) values ('index_lognum','10');
insert into {$db_prefix}options (option_name, option_value) values ('index_comnum','10');
insert into {$db_prefix}options (option_name, option_value) values ('index_twnum','10');
insert into {$db_prefix}options (option_name, option_value) values ('index_newtwnum','5');
insert into {$db_prefix}options (option_name, option_value) values ('index_newlognum','5');
insert into {$db_prefix}options (option_name, option_value) values ('index_randlognum','5');
insert into {$db_prefix}options (option_name, option_value) values ('index_hotlognum','5');
insert into {$db_prefix}options (option_name, option_value) values ('comment_subnum','20');
insert into {$db_prefix}options (option_name, option_value) values ('nonce_templet','default');
insert into {$db_prefix}options (option_name, option_value) values ('admin_style','default');
insert into {$db_prefix}options (option_name, option_value) values ('tpl_sidenum','1');
insert into {$db_prefix}options (option_name, option_value) values ('comment_code','n');
insert into {$db_prefix}options (option_name, option_value) values ('comment_needchinese','y');
insert into {$db_prefix}options (option_name, option_value) values ('comment_interval',60);
insert into {$db_prefix}options (option_name, option_value) values ('isgravatar','y');
insert into {$db_prefix}options (option_name, option_value) values ('isthumbnail','y');
insert into {$db_prefix}options (option_name, option_value) values ('att_maxsize','20480');
insert into {$db_prefix}options (option_name, option_value) values ('att_type','rar,zip,gif,jpg,jpeg,png,txt,pdf,docx,doc,xls,xlsx');
insert into {$db_prefix}options (option_name, option_value) values ('att_imgmaxw','420');
insert into {$db_prefix}options (option_name, option_value) values ('att_imgmaxh','460');
insert into {$db_prefix}options (option_name, option_value) values ('comment_paging','y');
insert into {$db_prefix}options (option_name, option_value) values ('comment_pnum','10');
insert into {$db_prefix}options (option_name, option_value) values ('comment_order','newer');
insert into {$db_prefix}options (option_name, option_value) values ('login_code','n');
insert into {$db_prefix}options (option_name, option_value) values ('reply_code','n');
insert into {$db_prefix}options (option_name, option_value) values ('iscomment','y');
insert into {$db_prefix}options (option_name, option_value) values ('ischkcomment','y');
insert into {$db_prefix}options (option_name, option_value) values ('ischkreply','n');
insert into {$db_prefix}options (option_name, option_value) values ('isurlrewrite','0');
insert into {$db_prefix}options (option_name, option_value) values ('isalias','n');
insert into {$db_prefix}options (option_name, option_value) values ('isalias_html','n');
insert into {$db_prefix}options (option_name, option_value) values ('isgzipenable','n');
insert into {$db_prefix}options (option_name, option_value) values ('isxmlrpcenable','n');
insert into {$db_prefix}options (option_name, option_value) values ('ismobile','n');
insert into {$db_prefix}options (option_name, option_value) values ('isexcerpt','n');
insert into {$db_prefix}options (option_name, option_value) values ('excerpt_subnum','300');
insert into {$db_prefix}options (option_name, option_value) values ('istwitter','y');
insert into {$db_prefix}options (option_name, option_value) values ('istreply','n');
insert into {$db_prefix}options (option_name, option_value) values ('topimg','content/templates/default/images/top/default.jpg');
insert into {$db_prefix}options (option_name, option_value) values ('custom_topimgs','a:0:{}');
insert into {$db_prefix}options (option_name, option_value) values ('timezone','8');
insert into {$db_prefix}options (option_name, option_value) values ('active_plugins','');
insert into {$db_prefix}options (option_name, option_value) values ('widget_title','$widget_title');
insert into {$db_prefix}options (option_name, option_value) values ('custom_widget','a:0:{}');
insert into {$db_prefix}options (option_name, option_value) values ('widgets1','$widgets');
insert into {$db_prefix}options (option_name, option_value) values ('widgets2','');
insert into {$db_prefix}options (option_name, option_value) values ('widgets3','');
insert into {$db_prefix}options (option_name, option_value) values ('widgets4','');
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯