i want delete any image in database with id_product I call, but the result just one image, not all image where id_product.
my database :
+------------------------------+
|id_image | id_product | image |
+------------------------------+
| 1 | 22 | ab.jpg |
| 2 | 22 | ak.jpg |
+------------------------------+
my controller :
function produk_dihapus(){
$id = $this->input->get('id');
$name = $this->input->get('name');
$this->produk_adm->hapus_any_image($id);
log_helper("produk", "Menghapus produk ".$name."");
}
my model :
function hapus_any_image($id){
$result = array();
$query = $this->db->get('produk_image',array('id_produk'=>$id));
foreach ($query->result_array() as $result)
{
//print_r($result);
unlink('assets/img/produk/'.$result['gambar']);
}
}
</div>