我有一个用户表,其中用户当前登录并没有上传照片(在用户表中的图像列是空的)显示的图像是Default.png。并且如果用户已经上传图片,则图像被显示。如何显示默认图像时场图像表是空
我的代码有什么问题?
这是我的表'user'对我的数据库(我很抱歉,我不能在这里写数据库结构)。
| id | gb_user | = | 1 | me.jpg |
此视图(headers.php):
<?php $user_log = info_user_login();?>
<?php if(!empty($user_log->gb_user) == NULL):?>
<img class="img-circle" src="../assets/img/default.png" width="70" style="margin:20px 0 0 10px;">
<?php else:?>
<img class="img-circle" src="../assets/img/<?php echo $user_log('gb_user');?>" width="70" style="margin:20px 0 0 10px;">
<?php endif;?>
这个辅助:
function info_user_login(){
$CI = & get_instance();
$CI->load->model('admin/setting_adm');
$get_data_login = $CI->setting_adm->get_data_log_user();
return $get_data_login;
}
和该模型:
function get_data_log_user(){
$id_login = $this->session->userdata('id');
$this->db->where('id', $id_login);
$this->db->from('user');
$q = $this->db->get();
return $q->result();
}
其中id = session_id_login
你的代码的实际行为是什么?在这种情况下,它不起作用:当用户**有**照片,或者当他**没有**或**都在**时?非工作情况下的输出是什么? – Sasha