在从数据库Codeigniter获取数据之前添加文本

时间:2018-11-08 06:38:57

标签: php codeigniter

我只想问一下在从数据库中获取数据之前,如何添加文本。我的代码看起来像这样

$GTextension = 'GT-';
    $UTextension = 'UT-';
    $rec_type = array(1472,1416,9752,1417,1500);//international,manila,province
    $last_receipt = $this->ion_auth->getLastReceipt($receipt);
    if($last_receipt->num_rows() > 0){
        if($receipt == 1){
            $newreceipt = $last_receipt->row()->inv_cno+1;
        }
        elseif($receipt == 2){
            $newreceipt = $last_receipt->row()->inv_cno+1;
        }
        elseif($receipt == 3){
            $newreceipt = $last_receipt->row()->inv_cno+1;
        }
        elseif($receipt == 4){
            $newreceipt = $last_receipt->row()-> $UTextension. inv_cno+1;
        }

因此可以在data之前添加文本。这就是我需要添加文字的地方

elseif($receipt == 4){
            $newreceipt = $last_receipt->row()-> $UTextension. inv_cno+1;
        }

所以看起来像这样

DR: UT-0001;

1 个答案:

答案 0 :(得分:1)

首先检查@MagnusEriksson评论。

然后尝试添加此内容

elseif($receipt == 4){
            $newreceipt = ++$last_receipt->row()->inv_cno;
            $newreceipt = $UTextension.$newreceipt;
 }

如果有错误,请发表评论