I have a bulletin board that displays data from the database. I want to display them in different categories and so I added a category column in my database ( with randomly assigned values category1, category2, category3)
If the user selects a category from a drop-down (which has distinct values from category column), the data corresponding to that category will be displayed. example.: if the user selects category1 from drop-down, the page should display the data corresponding to category1, if he selects category2.. etc.
My drop-down in view
<?php echo $this->Form->input('cat', array('type'=>'select', 'options'=>$data, 'label'=>false, 'empty'=>'CATEGORY')); ?>
and the value displayed as follows
<?php echo $post['Post']['category']; ?>
Post is my Model and category is the column name.
I am a beginner in cakePHP and right now clueless on how to proceed, any help will be appreciated.
I think I should be using following code
$selected_value = $this->request->data('Post.cat');
(Post being the Form )and then
if ($selected_value == category1){...}
but $selected_value is getting NULL, also I am still trying to figure out, how to extract and display, particular data.
May be by using such condition ?
$post['Post']['category'] == 'category1';
Anyway, still working on it and any help will be appreciated, Thank you!