⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

add button when no data, and unset add when exist data



carlinchisart
  • profile picture
  • Member

Posted 02 April 2012 - 15:28 PM

Hi all,

My question is: can i put the button add when i don't have data in my table, but unset the button add when i have data in my table?

so I used the function unset_add(); to no show the button add, only the eddit option, but if i don't have data in my table i have to show de add buton?

can i do this?

thanks, sorry if i repeat a topic.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 02 April 2012 - 19:23 PM

You don't repeat any topic, but you need a custom solution for this. It is quite easy, you just have to do something similar to this:


$crud = new grocery_CRUD();

$table_name = 'your_table';

$crud->set_table($table_name);

if($this->db->from($table_name)->count_all_results() > 0)
$crud->unset_add();


carlinchisart
  • profile picture
  • Member

Posted 02 April 2012 - 21:25 PM

you are the best!!!!!!!!!!!!!!!! more more thanks!!!