想要针对某个列值输出列值
Want to output column values against a certain column value
我想输出给定 luggage_id 的 bid_amount 列值。
下面是屏幕截图。
参考屏幕截图,例如,如果 luggage_id 是 123561,我只想得到 bid_amounts 255,25 和 88。
我的控制器
public function bid(){
$this->load->database();
$this->load->model('Truckeraccount_model');
$data['h']=$this->Truckeraccount_model->loads();
redirect('truckeraccount_ctrl/');
}
我的模型
public function loads() {
$luggage_id = $this->session->userdata('luggage_id');
$this->db->select('*');
$this->db->from('bids');
$this->db->where('luggage_id', $luggage_id);
$query = $this->db->get('bids');
return $query;
}
我的观点
<?php
foreach ($h->result() as $row)
{
?>
Luggage: <?php echo $row->luggage_id;?><br>
Bids: $<?php echo $row->bid_amount;?>
<?php } ?>
数据正在作为单独的行输出。
这样做
在控制器中
public function bid(){
$this->load->database();
$this->load->model('Truckeraccount_model');
$data['bids']=$this->Truckeraccount_model->loads();
# remove below and load view
//redirect('truckeraccount_ctrl/');
$this->load->view('name', $data);
}
模型中
public function loads() {
$luggage_id = $this->session->userdata('luggage_id');
$this->db->select('*');
$this->db->from('bids');
$this->db->where('luggage_id', $luggage_id);
$query = $this->db->get('bids');
$result = $query->result_array();
return $result;
}
在视图中
foreach ($bids as $bid) {
echo "Luggage ".$bid['luggage_id'];
echo "Bids ".$bid['bid_amount']; ;
}
我想输出给定 luggage_id 的 bid_amount 列值。 下面是屏幕截图。 参考屏幕截图,例如,如果 luggage_id 是 123561,我只想得到 bid_amounts 255,25 和 88。
我的控制器
public function bid(){
$this->load->database();
$this->load->model('Truckeraccount_model');
$data['h']=$this->Truckeraccount_model->loads();
redirect('truckeraccount_ctrl/');
}
我的模型
public function loads() {
$luggage_id = $this->session->userdata('luggage_id');
$this->db->select('*');
$this->db->from('bids');
$this->db->where('luggage_id', $luggage_id);
$query = $this->db->get('bids');
return $query;
}
我的观点
<?php
foreach ($h->result() as $row)
{
?>
Luggage: <?php echo $row->luggage_id;?><br>
Bids: $<?php echo $row->bid_amount;?>
<?php } ?>
数据正在作为单独的行输出。
这样做
在控制器中
public function bid(){
$this->load->database();
$this->load->model('Truckeraccount_model');
$data['bids']=$this->Truckeraccount_model->loads();
# remove below and load view
//redirect('truckeraccount_ctrl/');
$this->load->view('name', $data);
}
模型中
public function loads() {
$luggage_id = $this->session->userdata('luggage_id');
$this->db->select('*');
$this->db->from('bids');
$this->db->where('luggage_id', $luggage_id);
$query = $this->db->get('bids');
$result = $query->result_array();
return $result;
}
在视图中
foreach ($bids as $bid) {
echo "Luggage ".$bid['luggage_id'];
echo "Bids ".$bid['bid_amount']; ;
}