Buongiorno,
ho creato un form sul mio sito con Chronoforms V4 RC3.0.
Seguendo la guida
[size=78%]http://www.joomla.it/articoli-community-16-e-17-tab/5327-guida-2-joomla-17-e-chronoforms-interagire-con-il-database.html[/size],
ho provato a mostrare i dati. Vorrei però inserire un semplice campo di ricerca in modo da da visualizzare in elenco solo alcuni record salvati nel database.
Ho utilizzato l'action Db Multi Record Loader, nello spazio "Where statemet" ho inserito questo codice:
<?php
$session =& JFactory::getSession('ricerca');
$search_array = array('studente');
$cerca = array();
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
$cerca[] = " `$search` LIKE '%$value%' ";
}
}
if (empty($cerca) and (JRequest::getVar('submit','no','POST')=="Trova")) {
$session->set('cerca','0','ricerca');
JRequest::setVar('limitstart',0,'Get');
}
if ( !empty($cerca) ){
echo " WHERE ".implode(' AND ', $cerca);
$session->set('cerca',$cerca,'ricerca');
}
elseif ((JRequest::getVar('submit','no','POST')<>"Trova") and ($session->get('cerca',0,'ricerca')<>0))
{
$cerca=$session->get('cerca',0,'ricerca');
echo " WHERE ".implode(' AND ', $cerca);
}
else
{
echo "";
}
?>
e poi l'action "Custom Code" con le seguenti indicazioni:
<h2>Calendario Prove di settembre</h2>
<div style="text-align:center; width: 100%; ">
<p>Cerca in <b>Alunno</b>: <input type="text" name="studente" />
</p>
<p style="text-align:center;">
<input type="submit" value="Trova" name="submit" style='width:80px;
color:#cccccc; background-color:#339933; cursor:pointer;' />
<input type="reset" name="reset" value="Reset" style='width:80px;
color:#cccccc; background-color:#339933; cursor:pointer;' /></p>
<p style="text-align:center;"><b>Per resettare la ricerca lanciarla con campi vuoti</b></p>
<>
<div class="clr" style="border-bottom: 1px solid #222;"><><br/><br/>
<div>
<table style="text-align: center; width: 100%;" border="1" cellpadding="1" cellspacing="0">
<tbody>
<tr>
<td style="font-weight: bold; width: 5%;">Classe</td>
<td style="font-weight: bold; width: 30%;">Materia</td>
<td style="font-weight: bold; width: 15%;">Data</td>
<td style="font-weight: bold; width: 9%;">Ora</td>
<td style="font-weight: bold; width: 10%;">Aula</td>
</tr>
</tbody>
</table>
<>
<div>
<table style="text-align: left; width: 100%;" border="1" cellpadding="1" cellspacing="0">
<tbody>
<tr>
<td style="width: 5%;">{classe}</td>
<td style="width: 30%;">{materia}</td>
<td style="width: 15%;">{scritto}</td>
<td style="width: 9%;">{ora}</td>
<td style="width: 10%;">{aula}</td>
</tr>
</tbody>
</table>
<>
Cliccando su "trova" nel frontend, però, non mi dà nessun risultato. Immagino che il problema sia nel codice, ma non so come correggere. Qualcuno mi può aiutare? Grazie