User name is not being echoed

耗尽温柔 提交于 2019-12-12 04:10:34

问题


I made a link on a view on the CodeIgniter framework but the name of the user profile is not being echoed on the view. The link does work though.

<?php foreach($userdetail_list as $row){ ?>
<tr>
    <td>
        <a href="<?php echo base_url() . 'User/userdetails/'.$row['user_id']?>">
          <?php echo $row['name']; ?>
        </a>
    </td>
    <td>
        <?php echo $row['email'];?>
    </td>
</tr>
<?php } ?>

As you guys can see I'm making a link to the user profile with using the user_id but I'm also trying to echo the name of the user profile and that should be the link where someone could click on. Now there is a link to the user profile but its blank and it's not the name of the user.

Does someone know what I'm doing wrong?

Thanks!

printing userdetail list:

Array (
    [0] => Array (
        [user_id] => 6
        [email] => jeremy2@gmail.com
        [voornaam] => Jeremy
        [product_id] => 73
        [category_id] => 3
        [product_naam] => Tennisracket
    )
    [1] => Array (
        [user_id] => 4
        [email] => jeremy@gmail.com
        [name] => Jeremy
        [product_id] => 74
        [category_id] => 1
        [product_naam] => testcadeau
    )
)

getdata model function:

 function getdata($user_id){
  $this->db->select("*"); 
  $this->db->from('users');
  $this->db->where('user_id', $user_id);
  $query = $this->db->get();
  return $query->result();
 }

Controller function:

public function userdetails($user_id)
 {
  //load the User_model
  $this->load->model('User_model');

  //call function getdata in de Product_model
  $data['userdetail_list'] = $this->User_model->getdata($user_id);

  //laad view
  $data['main_content'] = 'profiel_user';
  $this->load->view('profiel_user',$data);
 }

来源:https://stackoverflow.com/questions/46545629/user-name-is-not-being-echoed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!