是否有可能从数据错误中生成二维码?

时间:2018-10-08 10:42:36

标签: php codeigniter qr-code

控制器部分:

$data['message']=$this->Member_model->add_member($params);
$data['member']=$this->Member_model->get_member($data['message']);
$data['qrdata']=$this->Member_model-> get_qrcodedata($data['message']);
$this->load->library('ciqrcode');
$qr_image=rand().'.png';

$params['data'] =   $data['qrdata'];

$params['level'] = 'H';
$params['size'] = 8;
$params['savename'] =FCPATH."uploads/qr_image/".$qr_image;
if($this->ciqrcode->generate($params)){
    $data['img_url']=$qr_image;
}

$data['_view'] = ('member/success');
$this->load->view('layouts/main',$data);

模型零件:

function get_qrcodedata($memID){
    $this->db->select('member.memregID,member.fullname,member.picture,member.currentDivision,member.mobileno,member.age');
    $this->db->from('member');
    $this->db->where('memID',$memID);
    $query = $this->db->get();
    //return  $num = $query->num_rows();
    return $query->result();
}

查看零件

<?php 
if($img_url){
?>
    <br><br>Your QRcode Image here. Scan this to get result<br>
    <img src="<?php echo site_url('uploads/qr_image/'.$img_url); ?>" alt="QRCode Image">
<?php
}
?> 

将生成Emtry Qrcode。在控制器部分 $ params ['data'] = $ data ['qrdata']; 中存储数据。由于 $ params ['data'] 的类型,我认为Qrcode为空。如何生成正确的Qrcode?谢谢:)

1 个答案:

答案 0 :(得分:0)

作为替代方案,我只是串起意想使字符串成为params文件。它的效率不高,但仍然有效。