PDF 没有在 Codeigniter 中显示名称而不是 id

PDF did not show name instead of id in Codeigniter

我有一个项目可以根据我点击的 id 显示证书。那 table 包含名称,id。但是每当我单击时,它都会显示 id 而不是 id 中的名称。

$nama = $this->db->query("SELECT nama FROM m_siswa where id = '$uri4' ")->result_array();
            /* $where = array('id' => $id);
            $person_info = $this->m_siswa->get($where);  */
            $viewData['id'] = $uri4;
            $this->load->view('v_sertifikat',$viewData);
            exit;

当我将 $uri4 更改为 $nama 时,它不起作用。注意$uri4是根据我点击的ID

$uri4 is id_siswa from table siswa, marked as 9720

但是当我单击“cetak sertifikat(或打印证书)到 pdf”时,它显示的是 id 而不是来自 $uri4 的名称

this is the output, but it did not show name

这是证书视图。

<div style=\"width:800px; height:600px; padding:20px; text-align:center;  #787878; margin-left: auto; margin-right: auto; \">

        <div  class='container-fluid' style=\"width:750px; height:550px; padding:20px; text-align:center;  #787878; margin: auto;  background-size: cover;\" >

            <span id='id1' style=\"font-size:30px; margin-top: -85px; \" ><img src=\"res/arkaplan6.jpeg\" alt=\"İKÜ LOGO\" height=\"795px\" width=\"1200px\"></span>

            <br><br>
             <br><br>
            <span style=\"font-size:50px; font-weight:bold\">SERTIFIKAT</span>
            <br><br>
            <br><br>
            <span style=\"font-size:30px\" ><b>$nama</b></span><br/><br/>
            <span style=\"font-size:25px\"><i>atas keberhasilannya telah mencapai nilai yang fantastis</i></span> <br/><br/>

            <span style=\"font-size:25px;\"><i>Anda telah lulus untuk sertifikat ini</i></span><br>
            <span style=\"font-size:10px\" ><b>id : $id</b></span><br/><br/>

             <br><br><br><br> <br> 

        </div>

注意$nama用于显示id中的名字,而不是id号。你能帮忙解决这个问题吗?

在 $name 中你得到你查询的结果作为数组

所以如果你想传递结果的内容,你应该

    $result = $this->db->query("SELECT nama FROM m_siswa where id = '$uri4' ")->result_array()


   $viewData['id'] = $uri4;
   $viewData['name'] = $result[0]['nama'];