I am currently facing a little problem. let me explain : I develop a database under cakphp 2.9 I use a custom search function, the problem is that when I click on the next page I have an error that appears (the first page is displayed without worries) this is my controller page : UsersController.php
public function search_club()
{
if (!empty($this->request->data)) {
$info1 = trim($this->request->data['Joueur']['CLUB']);
//debug($info1); die();
$joueurs = $this->Joueur->find('all', [
'conditions' => [
'AND' => [
'LOWER(Joueur.CLUB) LIKE' => '%' . strtolower($info1) . '%',
'Joueur.STATU' => '1'
]
]
]);
//debug($joueurs); die();
$this->Joueur->recursive = 0;
$this->paginate = [
'limit' => 20,
'conditions' => [
'and' => [
'Joueur.STATU' => '1',
'LOWER(Joueur.CLUB) LIKE' => '%' . strtolower($info1) . '%'
]
]
];
$joueurs = $this->paginate('Joueur');
$this->set('joueurs', $joueurs);
}
}
this is my view file
<?php
$paginator = $this->Paginator;
foreach ($joueurs as $joueur):
echo'<tbody>';
echo'<tr>';
echo '<td class="hidden-480">
<center>';
echo $joueur['Joueur']['LICENCES'];
echo'</center>
</td> ';
echo '<td class="hidden-480">
<center>';
echo $joueur['Joueur']['NOM'];
echo'</center>
</td> ';
echo '<td class="hidden-480">
<center>';
echo $joueur['Joueur']['PRENOM'];
echo'</center>
</td> ';
echo '<td class="hidden-480">
<center>';
echo $joueur['Joueur']['CLUB'];
echo'</center>
</td> ';
echo'<td>
<center>';
echo $joueur['Joueur']['SEXE'];
echo'</center>
</td>';
echo'<td>
<center>';
echo $joueur['Joueur']['NATIONALITE'];
echo'</center>
</td>';
echo'<td>
<center>';
echo $joueur['Joueur']['PROVEN'];
echo'</center>
</td>';
echo'<td>
<center>
<i class="ace-icon fa fa-eye-o"> </i>';
echo $this->Html->link('Modifier/Voir',
array('controller' => 'users', 'action' => 'edit_play', $joueur['Joueur']['id']),array('target' => '_blank'));
echo'</center>
</td>';
echo '<td class="hidden-480">
<center>';
echo $this->Form->postLink(__('Supprimer'), array('action' => 'delet_play', $joueur['Joueur']['id']), null, __('Etes vous sûr de vouloir supprimé cet élément ?', $joueur['Joueur']['PRENOM']));
echo'</center>
</td>
</tr>
</tbody>';
endforeach;
unset($joueur);
echo'</table>
</div>
</div>
</div>
</div>';
echo'
<div style="height:50px!important">
</div>';
// pagination section
echo "<div class='paging' style='text-align:center'>";
// the 'first' page button
echo $paginator->first("Debut");
// 'prev' page button,
// we can check using the paginator hasPrev() method if there's a previous page
// save with the 'next' page button
if($paginator->hasPrev()){
echo $paginator->prev("Precedent");
}
// the 'number' page buttons
echo $paginator->numbers(array('modulus' => 3));
// for the 'next' button
if($paginator->hasNext()){
echo $paginator->next("Suivant");
}
// the 'last' page button
echo $paginator->last("Fin");
echo "</div>";("Fin");
echo" </div>
</div>";
?>
</div>
now this is this the error i got when a click on next page
Notice (8): Undefined variable: joueurs [APP/View/Elements/resume_search_club.ctp, line 174]
Warning (2): Invalid argument supplied for foreach() [APP/View/Elements/resume_search_club.ctp, line 174]
I've been looking for a solution for several days, so please I really need your help on this one
Thanks in advance