型号:
public function show_data_by_tid_pic($postid,$postpic) {
$condtid = "otslm.tid =" . "'" . $postid . "'";
$condpic = "pic.nama =" . "'" . $postpic . "'";
$this->db->select('otslm.*');
$this->db->select('pic.*');
$this->db->from('otslm');
$this->db->join('pic', 'pic.id = otslm.id');
$this->db->where($condtid);
$this->db->where($condpic);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result(); } else {
return false;
}
}
控制器:
public function inputslm() {
$postid = $this->input->post('nametid');
$postpic = $this->input->post('namepic');
if ($postid != "" OR $postpic != "") {
$resultid = $this->skejuler_model->show_data_by_tid_pic($postid,$postpic);
if ($resultid != false) {
$data['result_display'] = $resultid;
}
else {
$data['result_display'] = "Not Found!";
}
}
else {
$data = array(
'tid_error_message' => "TID tidak boleh kosong!",
'pic_error_message' => "PIC tidak boleh kosong!"
);
}
$data['show_table'] = $this->view_table();
$this->load->view('front/dashboard', $data);
}
查看:
if (isset($result_display)) {
if ($result_display == 'Not Found!') {
echo $result_display;
} else {
foreach ($result_display as $vid) {
$zlokasi = $vid->lokasi;
$znama = $vid->nama;
$znohp = $vid->nohp;
}
echo $zlokasi;
echo "<br>";
echo $znama;
echo "<br>";
echo $znohp;
}
}
提交后:
我是codeigniter的新手,尝试通过将表与两个字段“nametid”和“namepic”连接来生成数据。我认为代码没有错,存在列,但它总是变成假的(找不到!)。请帮我弄清楚。。。非常感谢你。。。
使用heidisql(找到行:0),联接表因where子句而失败。图1
使用heidisql(找到行:31),在没有where子句的情况下连接表success。图2
1条答案
按热度按时间fruv7luv1#
获取数据现在成功,不使用联接,将查询替换为: