中易网

THINKPHP中怎么提取这种数据表形式的数据显示在模板中?

答案:2  悬赏:50  
解决时间 2021-02-16 21:43
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};为啥不能提出呢



最佳答案
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>
全部回答
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','');
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
夏天用海杆早晨钓鲢鱼漂调多深水
中国邮政(姜州邮政支局)在什么地方啊,我要过
03款奥迪老a6发动机仓几个小真空管图片,怎么
轻裁减去车子旁加上什么旁等于什么字可以组什
立晴在哪里啊,我有事要去这个地方
ACM求大神错哪里了,hdu2010水仙花数
公务员笔试通过后有一个信息审查。如果我在笔
底面直径和高都是10厘米的圆柱,侧面展开后得
佳艺发型设计在什么地方啊,我要过去处理事情
一次复印身份证正反面
智联招聘上的简历开放方式中的开放和委托给智
螺母对边19*21.9是什么意思
99年欧冠决赛那两支球队 曼联和拜仁 从阵容上
友谊大街23号街坊东门在什么地方啊,我要过去
重庆市涪陵区助学贷款怎么办
推荐资讯
掮客怎么读音是什么
福万家超市(百盛西)地址在哪,我要去那里办事
矛盾的矛少一笔是什么字
玉盛杂品百货怎么去啊,有知道地址的么
求元气囝仔语录
安徽省成人教育派遣证和统招教育派遣证区别?
求《论语》鉴赏?
女人来月经时是不是会胡思乱想
罗晋参加了哪季哪期全员加速中
分手后,还要不要继续联系呢?
项链有哪些花型?哪种配坠子最好?
每天都听BBC 有用吗
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?