CodeIgniter Forums
check exist value coincidence - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: check exist value coincidence (/showthread.php?tid=52354)



check exist value coincidence - El Forum - 06-07-2012

[eluser]Gabi3xz[/eluser]
I have a code for check exist a category in datebase
Code:
$result_cat = $this->call_db->category_check($this->input->post('cat_name'));
if ( $result_cat != false ) {
        echo 'Category not exist';
}
Works good but example
I go to a page for edit category, value category should always be another value because their finds value in the database and forced me to change the value category.
Iow do I solve?


check exist value coincidence - El Forum - 06-07-2012

[eluser]Glazz[/eluser]
Can you explain, better, what is wrong with your code ?




check exist value coincidence - El Forum - 06-07-2012

[eluser]Gabi3xz[/eluser]
Code is not wrong, problem is I want to edit an existing value and this code check the current value in datebase and I say that exist and forced me to change it


check exist value coincidence - El Forum - 06-07-2012

[eluser]Glazz[/eluser]
Hmm i still don't understand very well, your english is not the best..

You should update a row on the database using his unique id.

Something like this:
Code:
$params = array(
   'cat_name' => $this->input->post('cat_name')
);
$this->db->where('cat_id', $your_cat_id_here)->update('categories_table_name', $params);

Where you have $your_cat_id_here it is the category unique id on the database.


check exist value coincidence - El Forum - 06-07-2012

[eluser]Gabi3xz[/eluser]
look here
http://img69.imageshack.us/img69/7153/dadsasd.jpg