I am a beginner in CakePHP. I want to do a simple search box, but it is not working, below is the code in my controller:-
public function index() {
if ($this->request->is('post')) {
$this->loadModel('Job');
$this->request->data = $keyword;
$result = $this->Job->find('all', array(
'condition'=>array('Job.title'=>'% $keyword %')
));
$this->set('rslt',$result);
//$this->set('kc',$keyword);
}
}
For my view, I have the code below:-
<?php echo $this->Form->create('search', array('type'=>'get'));?>
<?php echo $this->Form->input('search');?>
<?php echo $this->Form->end('Submit');?>
<pre><?php print_r($rslt) ; ?></pre>
However the search result displays a blank page.
Change this:
to this:
That is, remove the spaces, else the generated SQL will try to find the keyword surrounded by spaces.