网上找的,不过估计新手用的时候会出错,所以修改下教程,分享给大家。
1. 在/include中 查找到 global.func.php 这个文件
在这个文件中添加一个函数:
function company_setting($userid, $key = '', $cache = '') {
global $db;
if($key) {
$r = $db->get_one("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid AND item_key='$key'", $cache);
return $r ? $r['item_value'] : '';
} else {
$setting = array();
if($cache) {
$query = $db->query("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid", $cache);
} else {
$query = $db->query("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid", $cache);
}
while($r = $db->fetch_array($query)) {
$setting[$r['item_key']] = $r['item_value'];
}
return $setting;
}
}
循环中调用方法
{company_setting($t[userid], $key = 'logo', $cache = '')}
第二种方法:
include/global.func.php最下面加入
function gets_company_setting($userid, $key = '', $cache = '') {
global $db;
if($key) {
$r = $db->get_one("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid AND item_key='$key'", $cache);
return $r ? $r['item_value'] : '';
} else {
$setting = array();
if($cache) {
$query = $db->query("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid", $cache);
} else {
$query = $db->query("SELECt * FROM {$db->pre}company_setting WHERe userid=$userid", $cache);
}
while($r = $db->fetch_array($query)) {
$setting[$r['item_key']] = $r['item_value'];
}
return $setting;
}
}
模板调用
<a href="{userurl($t[username])}" target="_blank" title="{$t[company]}"><img src ="{gets_company_setting($t[userid], $key = 'logo', $cache = '')}" alt="{$t[company]}"/></a>