报告ID

Report where id

我在打印基于 ID 的数据时遇到问题, 错误:

Too few arguments to function M_order::cetak_db_order(), 0 passed in C:\xampp\htdocs.......\Order.php on line 162 and exactly 1 expected

提交id

<td class="text-center"><a href="<?php echo base_url(); ?>backend/order/cetak_order/<?php echo $m->id_service; ?>" class="btn bg-navy btn-flat margin">Detail order</a></td>

型号代码

 public function cetak_db_order($id){
    $hasil=$this->db->query("
        SELECT id_service,kd_cs,nama_cs,reciver_name,tanggal,status,nama_kecamatan AS tujuan, nama_kabupaten AS asal 
        FROM service s
        INNER JOIN customers c ON s.id_cs=c.id_cs 
        INNER JOIN kabupaten k ON s.id_origin=k.id_kab 
        INNER JOIN kecamatan p ON p.id_kec=s.id_destination WHERE id_service='$id'");
    return $hasil->result();
}

控制器代码

public function cetak_order(){
    $pdf = new FPDF('l','mm','A5');
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);

    $pdf->SetFont('Arial','B',10);
    $pdf->Cell(20,6,'Nama',1,0);
    $pdf->Cell(85,6,'penerima',1,0);
    $pdf->Cell(27,6,'asal',1,0);
    $pdf->Cell(25,6,'tujuan',1,1);
    $cetakorder = $this->M_order->cetak_db_order();
    foreach ($cetakorder as $row){
        $pdf->Cell(20,6,$row->nama_cs,1,0);
        $pdf->Cell(85,6,$row->reciver_name,1,0);
        $pdf->Cell(27,6,$row->asal,1,0);
        $pdf->Cell(25,6,$row->tujuan,1,1); 
    }
    $pdf->Output();
}

您正在从 HTML 中的锚标记传递 $m->id_service。但是您没有在 PHP.

中的任何地方使用它

您需要更新 cetak_order 函数,如下所示:

public function cetak_order( $id ){
.
.
.
.
.
$cetakorder = $this->M_order->cetak_db_order( $id );

此外,您还需要确保从任何调用它的地方将 $id 传递给 cetak_order 方法,除非它由您的路由器自动传递。