From Chronoconnettivity to latest Chronoforms

ciconet 29 Nov, 2011
Hello guys

i'm a new user and i want to copy one simple search function from my old joomla 1.5 with chronoconnettivity to this latest version chronoforms in joomla 1.7
I've created form table with DB Multi Record Loader and all work fine. But i don't find the way to work old searching custom function from joomla 1.5 connettivity to this one new.

Scenario is ( joomla 1.5 with connettivity )

Into WHERE SQL:
<?php $session =& JFactory::getSession('ricerca'); $search_array = array('select_20','select_8','select_2'); $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 ""; }?>


Into HEADER:
<?php
JHTML::_('behavior.modal');
?>
<?php
$style = "";
$style .= "
table.cf_listing {
margin-bottom: 12px;
}
";
if ( $style) {
$doc =& JFactory::getDocument();
$doc->addStyleDeclaration($style);
}
?>
</br>
<p style="text-align:right; color:black;"><b>RICERCA :: Per elencare tutti i risultati, lascia i campi vuoti ed clicca su Trova </b></p>
<div style="float:left; width: 100%; "><p></br> <b>Provincia</b>: <input type="text" name="select_20" /><b>Taglia</b>: <input type="text" name="select_8" /><b>Tipo animale</b>: <input type="text" name="select_2" /></p)<p style="text-align:center;"><input type="submit" value="Trova" name="submit" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /><input type="reset" name="reset" value="Reset" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /></p></br></div>

<table class='cf_listing'>
<table width="100%" border=”2” align="center">
<thead>
<tr>
<th>Provincia</th><th>Data</th><th>Nome</th><th>Tipo Animale</th><th>Razza</th><th>Sesso</th><th>Taglia</th><th>Dettagli</th></tr>
</thead>
<tfoot>
<tr>
<td colspan='12' style='height:2px; background:#135cae;'></td>
</tr>
</tfoot>
<tbody>


Into BOBY:
<tr><td align="center">{select_20}</td><td align="center">{recordtime}
</td><td align="center">{text_19}</td><td align="center">{select_2}</td><td align="center">{select_3}</td><td align="center">{select_5}</td><td align="center">{select_8}</td><td align="center">
[ <a class='modal' href='index.php?option=com_chronocontact&chronoformname=dettaglio_affido&cf_id={cf_id}&tmpl=component' rel="{handler: 'iframe', size: {x:620, y: 530}}" >dettagli</a> ]</td>
</tr>


Into FOOTER:
</tbody>
</table>
<br></br>
<p>{pagination}</p>



Now, where i have to put this sections to work correctly with new chronoforms and joomla 1.7 ?
I put the Header, Body and Footer like a Custom Code ( see attachement ) but WHERE SQL ???
I try to put into WHERE STATEMENT not work...

What i wrong ?

Here you can see how the form work ( with connettivity and joomla 1.5 ):
http://spaziofile.altervista.org/cani/index.php?option=com_chronoconnectivity&connectionname=Adozioni

Thanks in advance for your help
GreyHead 30 Nov, 2011
Hi ciconet,

I think you need to use the DB Multi Record Loader action - there's a WHERE box on the Advanced tab.

Bob
Max_admin 01 Dec, 2011
Hi ciconet,

The search in V4 is easy and I have already explained it in another post the last month, did you get the data list working following the V4 tutorial "Multi record loader" under our "Tutorials" page ?

Once you do you can do the search easily, you only need a small PHP code snippet in the WHERE box as Bob mentioned, if you can't find it then let me know and I will post it again here.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ciconet 02 Dec, 2011
Thanks for your answers

Bob: The first things that i had to do is to put code into WHERE ( in DB Multi Record loader - Advanced ). If i put code into there, i can't see anything on my table. So some thing don't work....

Max: I'm looking for this solution since November and i don't find nothing. Can you show me link to your tutorial ? Maybe, i don't see it beacuse i was concentrated to code !

Thanks to all
ciconet 02 Dec, 2011
Thanks for your answers

Bob: The first things that i had to do is to put code into WHERE ( in DB Multi Record loader - Advanced ). If i put code into there, i can't see anything on my table. So some thing don't work....

Max: I'm looking for this solution since November and i don't find nothing. Can you show me link to your tutorial ? Maybe, i don't see it beacuse i was concentrated to code !

Thanks to all
GreyHead 02 Dec, 2011
Hi ciconet,

But what code have you got in the WHERE box? If it isn't working then it's probably got a typo or bug in it.

Note in particular that ChronoConnectivity required you to add the word WHERE to the statement and CFv4 doesn't

Bob
ciconet 05 Dec, 2011
In WHERE Statement i've tryed to put this code:

<?php $session =& JFactory::getSession('ricerca'); $search_array = array('select_20','select_8','select_2'); $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 ""; }?>


If this code is into WHERE Statement, i can't see no table and no results ( and searching not work ! ), otherwise if i remove this code from the WHERE Statement, table work fine with result but i don't fix problem.

The code work fine on connettivity. I need to remove WHERE into code ? And how can i replace it ?

Thanks so much
ciconet 06 Dec, 2011
Hi guys

any idea about this ?

Or, i need to left this code and replace with other one ?

Max you wrote: "search easily, you only need a small PHP code snippet in the WHERE box as Bob mentioned"
Can you explain me ? I followed the v4 DB Multi tutorial and i get the data, but i also need this search function...

Thanks, Alex
ciconet 06 Dec, 2011
Someone can help me ?

Can i have a simple working code for search in v4 ? Or can someone point me in the right direction ?

Thanks for help

Alex
Max_admin 07 Dec, 2011
Hi Alex,

Sorry, I got busy with some stuff.

Ok, a simple search form will have this:

On Load:
1- Show HTML

On Submit:
1- DB Multi record loader
2- Custom code (Optional step, use a "Debugger" action instead)
3- Event Loop (optional: only in case you want to redisplay the form below the results)

The DBMRL in the "on Submit" will need to have 3 things configured, the "Table name", "Model ID" and the "WHERE" box, the "Where" box should have something like (but not limited to) this:
`db_field_name_1` LIKE '%<?php echo $form->data['my_form_field_name_1']; ?>%' OR `db_field_name_2` LIKE '%<?php echo $form->data['my_form_field_name_2']; ?>%'


Note that you will need to replace the "db_field_name_1" with a real field name in your DB table and replace the "my_form_field_name_1" with a real form field name.

You may also change the "OR" to "AND" based on your requirements.

The "Custom code" will have a code to "display" the results, as pointed above, you may replace this by a "Debugger" action to let you see the actual results returned in the form data array, if they are ok then you may remove it and use the "Custom code" to display the results using a foreach loop:


<?php
foreach($form->data['model_id_here'] as $record){//note that the "model_id" need to be replaced
echo $record['my_field_name_1'];
echo "<br />";
}
?>


Optional: add a "Data to Session" action before the "DBMRL" in the "On Submit", this will save the search query in the session and will load the last found results if the user returned to the same submit url again.

The new Connectivity is finished for the admin area only, multi tables support available, but there is no frontend features yet, hopefully soon.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ciconet 07 Dec, 2011
Hello Max,

thanks for your answer !

I followed your steps and now i have this ( see image below ).

[attachment=0]Immagine.jpg[/attachment]

First one - My form setting are:

Form name -> primanota
Published -> Yes
Tight Layout -> normal

In EVENT:

ON LOAD
1) Show Html
2) Custom Code - Header:

<p style="text-align:right; color:black;"><b>RICERCA :: Per elencare tutti i risultati, lascia i campi vuoti ed clicca su Trova </b></p>
<div style="float:left; width: 100%; "><p></br> <b>Nome</b>: <input type="text" name="nome" /><b>Cognome</b>: <input type="text" name="cognome" /></p)<p style="text-align:center;"><input type="submit" value="Trova" name="submit" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /><input type="reset" name="reset" value="Reset" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /></p>

For show the field to be entry data from users with: Trova and Reset buttons.
Now i want to be searchable the fields: 'nome' and/or 'cognome'

ON SUBMIT

1) DB Multi record loader
-BASIC:
- Table name -> avjos16_chronoforms_data_Cassa
- Model ID -> UserDetails
- Other fields are empty ( default )

-ADVANCED
- Load Data -> Yes ( default )
- Enable associations -> No ( default )
- Associations Models -> empty ( default )
- Group Model Data -> Yes ( default )
- WHERE Statement ->

`nome` LIKE '%<?php echo $form->data['primanota']; ?>%' OR `cognome` LIKE '%<?php echo $form->data['primanota']; ?>%'


2) Custom Code - codice:

<?php
foreach($form->data['UserDetails'] as $detail):
($date = $detail['cf_created']);
($dateTime = new DateTime($date));
($formatted_date=date_format ( $dateTime, 'd-m-Y' ));
($formatted_hour=date_format ( $dateTime, 'h:i:s' ));
JHTML::_('behavior.modal');
?>
<tr>
<td align="center"><?php echo $detail['cf_id']; ?></td>
<td align="center"><?php echo $detail['operazione']; ?></td>
<td align="center"><?php echo $formatted_date; ?></td>
<td align="center"><?php echo $formatted_hour; ?></td>
<td align="center"><?php echo $detail['nome']; ?></td>
<td align="center"><?php echo $detail['cognome']; ?></td>
</tr>

In this code i've added date rotation function for Italy🙂

3) Event Loop

I'm sorry to inform you that not show any result and Trova or Reset buttons not make any reaction. I think i've not understood the functionally of this DB Multi Record Loader ...

Can you check it ?

Thanks again for your help.

Alex
Max_admin 08 Dec, 2011
Hi Alex,

Did you try to use the "Debugger" as I suggested to check if there is any data returned ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ciconet 08 Dec, 2011
Hello Max

yes sure. I tried to put the debuger before Custom code ( or i need to remove custom code ? ). So, how can i see debug ? I try to run page, and when i return to debugger module, it's always empty...

Alex
Max_admin 08 Dec, 2011
Before the "Custom code" is ok, but the debugger should display some data, could you please show me as screenshot ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 08 Dec, 2011
There are no form tags in this page, did you disable the "Show form tags" setting in your form "Edit" page ?

Also, I need some data to search for ? to make sure that I will get some results.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ciconet 08 Dec, 2011
Max,

i don't have disabled the "Show form tags" setting in my form "Edit" page, or i hope i never have done it because i don't find this setting, only "Form tag attachment" empty field and "Add form tags" set to Yes and "Form method" set to Post.

This image show to you table with test data:

[attachment=0]data_search.png[/attachment]

You can try to find "nome" -> Ale or Pippo or Roberta. You can find too "cognome" like Cot or Baudo or lisa
Max_admin 09 Dec, 2011
I'm still not able to submit your form, when I click on the "Trova" button, nothing happens!!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ciconet 09 Dec, 2011
yes Max,

this is exactly my first problem: everything i do, add and remove code, change order of Event and other ... the buttons Trova and Reset have never been working !

I think there missing something, but what ?
GreyHead 10 Dec, 2011
Hi ciconet ,

It looks to me as though the <form> tags still aren't set. Please see Max's earlier post.

Bob
ciconet 10 Dec, 2011
Hi Bob,

i'm by now lost in code ...

Where i have to put tags <form> ??? Can you suggest to me ?

Or can you show me reporting my previous published code ?

Thank so much

Alex
crea2k 12 Dec, 2011
I have followed the post as I am interested in putting in a search box. I started with a blank form and followed the directions on the previous page.
I know there is a name 'Iain' in the database so I tried searching for that, the result I get is :



Warning: Invalid argument supplied for foreach() in C:\server2go\server2go\htdocs\chandlers\administrator\components\com_chronoforms\form_actions\custom_code\custom_code.php(18) : eval()'d code on line 2
Data Array: 
Array
(
    [input_text_1] => iain
    [input_submit_0] => Submit
    [03c2e756b86dad319ebfa2b21cf38276] => 1
    [option] => com_chronoforms
    [chronoform] => searchform
    [event] => submit
    [Itemid] => 
    [cf_id] => 3
    [cf_uid] => e410dc9ec60e813d8839bbf9c4e6dcf7
    [cf_created] => 2011-12-10 22:09:18
    [cf_modified] => 2011-12-11 23:28:18
    [cf_ipaddress] => 127.0.0.1
    [cf_user_id] => 42
    [viewallleads] => 
    [sentletterday] => NA
    [sentlettermonth] => NA
    [sentletteryear] => NA
    [sentpostcardday] => 5
    [sentpostcardmonth] => april
    [sentpostcardyear] => 2013
    [sentquoteday] => NA
    [sentquotemonth] => NA
    [sentquoteyear] => NA
    [addnewlead] => 
    [leadname] => Betty Smith
    [messagetemplates] => 
    [salutation] => miss
    [emailmanagement] => 
    [businessname] => Betties Boots
    [address1] => nkjnk
    [deletelead] => 
    [address2] => df
    [address3] => df
    [address4] => df
    [thankyouemail] => 
    [sorryemail] => 
    [reminderemail] => 
    [orderthankyouemail] => 
    [county] => dfd
    [postcode] => LN57JS
    [gasoiluser] => yes
    [annualconsgasoil] => 34
    [gasoilmargin] => 43
    [dervuser] => 
    [annualconsgasderv] => 
    [dervmargin] => 
    [kerouser] => yes
    [annualconskero] => 34
    [keromargin] => 34
    [fueldetails] => dsf
    [thankyoupostPDF] => 
    [sorrypostPDF] => 
    [remindpostPDF] => 
    [orderthankyoupostPDF] => 
    [lubesdetails] => sdf
    [othernotes] => df
    [updatelead] => Add / Update
)
Debug Data
db_record_loader
SELECT * FROM `hqfjt_chronoforms_data_addupdatelead` AS `searchdetails` WHERE `leadname` LIKE '%%' OR `businessname` LIKE '%%'


So I am not sure what I have done wrong as it doesn't seem to be working as expected ?.
GreyHead 13 Dec, 2011
Hi crea2k,

What is on line 2 of your custom code action? That's where the error message is saying that there is a problem.

Bob
ciconet 13 Dec, 2011
Hello Bob,

as you and max suggested, i tried to put the <form> tags in this way ( Custom code - Header ):

<form>
<p style="text-align:right; color:black;"><b>RICERCA :: Per elencare tutti i risultati, lascia i campi vuoti ed clicca su Trova </b></p>
<div style="float:left; width: 100%; "><p></br> <b>Nome</b>: <input type="text" name="nome" /><b>Cognome</b>: <input type="text" name="cognome" /></p)<p style="text-align:center;"><input type="submit" value="Trova" name="submit" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /><input type="reset" name="reset" value="Reset" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /></p>
</form>

now, the button Reset seems to work ( clear all content inside searching nome and cognome box ), but the button Trova reload the same page without result.

You can try here: http://umbynet.altervista.org/portale/prima-nota

Any additional suggest ??

Thanks for your help

Alex
GreyHead 15 Dec, 2011
Hi Alex,

I don't think that we intended to suggest that. Those <form> tags won't do much. I don't understand whay the tags aren't showing as standard unless you hae accidentally turned them off on the Form General tab.

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
GreyHead 16 Dec, 2011
Hi Alex,

I think that you have mos tof the eight bits but they are jumbled up a little.

Please remove the <form> tags you added - they aren't helping.

Then take the ramining code from the Custom Code action and copy and paste it into a Custom Code element in the Preview box. (At present the Preview box is empty and it seems that makes ChronoForms leave out the <form> tags).

Remove the Custom Code action.

You should now have a form that submits OK when you click the Trova button (though it then loops until it runs out of memory).

Next, copy the Multi Record Loader into the On Load action and remove the one in the On Submit action.

Then copy the Custom code - codice action into the On Load event and remove the one in the On Submit action.

Lastly go the Form General tab and set the Action/On Submit URL to the form URL so that it submits to itself.

That should get you the main blocks in the correct locations and hopefully the form will run.

NB I have not checked the detail of your code at all.

Bob
ciconet 17 Dec, 2011
Hello Bob,

inline what i have done:

You write: "Please remove the <form> tags you added - they aren't helping."
- Ok, done!

You write: "Then take the ramining code from the Custom Code action and copy and paste it into a Custom Code element in the Preview box. (At present the Preview box is empty and it seems that makes ChronoForms leave out the <form> tags)."

-Not done: Preview box is not editable. haw can i edit it or move the custom code into it ?

You write:"You should now have a form that submits OK when you click the Trova button (though it then loops until it runs out of memory)."
- No, not work

You write: "Next, copy the Multi Record Loader into the On Load action and remove the one in the On Submit action."
-Ok, done!

You write: "Then copy the Custom code - codice action into the On Load event and remove the one in the On Submit action.
-Ok, done!

You write:"Lastly go the Form General tab and set the Action/On Submit URL to the form URL so that it submits to itself."
-The only one value is "Submit action"and i had to set it to "self". Default value is "Submit". See image below

[attachment=1]form_tab.jpg[/attachment]

You write: "That should get you the main blocks in the correct locations and hopefully the form will run."
- Those are the new positions of the blocks. See image below

[attachment=0]block.jpg[/attachment]

Now, if you load the form ( http://umbynet.altervista.org/portale/index.php?option=com_chronoforms&chronoform=Primanota_PENNISI ) you can see table with all results, but with invalid searching form ( Trova and Reset buttons )

If you want, i can give access to you into joomla administrator panel in PM.

Thanks BOB

Alex
GreyHead 17 Dec, 2011
Hi ciconet,

copy and paste it into a Custom Code element in the Preview box.

You need to drag a Custom Code element from the left hand side into the Preview box to get this to work.

Bob
ciconet 19 Dec, 2011
Hello Bob,

after many hours into it i've made more changes and now i want to show to you the refreshed situation :

You write: "Please remove the <form> tags you added - they aren't helping."
- Ok, done!

You write: "Then take the ramining code from the Custom Code action and copy and paste it into a Custom Code element in the Preview box. (At present the Preview box is empty and it seems that makes ChronoForms leave out the <form> tags)."
- Ok, done!
[attachment=2]Preview.jpg[/attachment]


You write:"You should now have a form that submits OK when you click the Trova button (though it then loops until it runs out of memory)."
- Ok, work but not show results

You write: "Next, copy the Multi Record Loader into the On Load action and remove the one in the On Submit action."
-Ok, done!

You write: "Then copy the Custom code - codice action into the On Load event and remove the one in the On Submit action.
-Ok, done!

[attachment=1]Custom_Code.jpg[/attachment]

You write:"Lastly go the Form General tab and set the Action/On Submit URL to the form URL so that it submits to itself."
-Ok, done! ( i think it's right )

[attachment=0]Form_setting.jpg[/attachment]

Now, if you load the form ( http://umbynet.altervista.org/portale/prima-nota ) you can see table with all results on head, Trova button seems to work but does not show results and Reset button not work.
GreyHead 19 Dec, 2011
Hi ciconet,

If I understand correctly you now have a working form except that the results aren't displaying where you need them (they are a the top of the page instead of in the table); and the Reset Button doesn't work.

I've checked the HTML for the Reset button and if you take the Form HTML and put it into a new HTML page the Reset button works. So something else in your page is breaking it.

The layout problem looks as though you have the sequence wrong in the On Load box. The results table header is showing after the main body of the results.

Bob
ciconet 19 Dec, 2011

If I understand correctly you now have a working form except that the results aren't displaying where you need them (they are a the top of the page instead of in the table); and the Reset Button doesn't work.


Yes. correctly.

Code of the searching box ( with Trova and Reset buttons ) is:

<p style="text-align:right; color:black;"><b>RICERCA :: Per elencare tutti i risultati, lascia i campi vuoti ed clicca su Trova </b></p>
<div style="float:left; width: 100%; "><p></br> <b>Nome</b>: <input type="text" name="nome" /><b>Cognome</b>: <input type="text" name="cognome" /></p)<p style="text-align:center;"><input type="submit" value="Trova" name="submit" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /><input type="reset" name="reset" value="Reset" style='width:70px; color:#cccccc; background-color:#135cae; cursor:pointer;' /></p>


I've try to rebuilg new form from the begin with always the same results for Trova button ( work and reload empty page with no result ) and for Reset ( not work )

The layout problem looks as though you have the sequence wrong in the On Load box. The results table header is showing after the main body of the results.



I think the DBMRL not work ! Can you check it ?

On WHERE Statement there are this code:

`nome` LIKE '%<?php echo $form->data['UserDetails']; ?>%' OR `cognome` LIKE '%<?php echo $form->data['UserDetails']; ?>%'


The UserDetails is the ModelID into DBMRL. This is right ?

[attachment=1]DBMRL.jpg[/attachment]

Trying to modify box order in OnLoad nothing to do.

If i put one ShowStopper, Layout seems to be ok... ( see now: http://umbynet.altervista.org/portale/prima-nota )

[attachment=0]Onload_Block.jpg[/attachment]
GreyHead 19 Dec, 2011
Hi ciconet,

If the results are displaying in the wrong place then the problem is the layout; not the database query.

Bob
ciconet 19 Dec, 2011
hi Bob,


the results are displayed only without the searching function.

The reason of this topic is not the display result, but the search function !

So, can you check please the DBMRL data is correct as i shown in previus post ? I think the DBMRL not work or i wrong something in code WHERE ......


Alex
GreyHead 19 Dec, 2011
Hi ciconet,

The WHERE code looks OK to me. If you turn on Site Debug you can see all the generated MySQL queries and check if the DB query is correct.

Bob
ciconet 20 Dec, 2011
Hi Bob,

Now i've put the debugger into the blocks in this way:
[attachment=0]debug.jpg[/attachment]

and i can see all the result loaded into form ( this is when page is loaded ):

Data Array: 
Array
(
    [Itemid] => 136
    [option] => com_chronoforms
    [view] => form
    [UserDetails] => Array
        (
            [0] => Array
                (
                    [cf_id] => 1
                    [cf_uid] => 4935935850883e1a0cf050967227a696
                    [cf_created] => 2011-11-28 11:55:14
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => Ale
                    [cognome] => Cot
                    [importo] => 100
                    [importomeno] => 
                    [segnomeno] => 
                    [modalita] => contanti
                    [causale] => ricaricatel
                    [dettagli] => ricvoip
                    [data] => 2011-11-10 11:55:09
                    [operazione] => Versamento
                    [input_submit_10] => Invia DATI
                )

            [1] => Array
                (
                    [cf_id] => 2
                    [cf_uid] => 313a0fec9b760a028cfe4b309f3a1e3e
                    [cf_created] => 2011-11-28 11:57:58
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => Pippo
                    [cognome] => Baudo
                    [importo] => 
                    [importomeno] => 50
                    [segnomeno] => -
                    [modalita] => assegno
                    [causale] => rictim
                    [dettagli] => Ricarica TIM
                    [data] => 2011-11-28 11:57:53
                    [operazione] => Prelievo
                    [input_submit_10] => Invia DATI
                )

            [2] => Array
                (
                    [cf_id] => 4
                    [cf_uid] => 98403bdcabb2969d18ffd57e3a5d1e22
                    [cf_created] => 2011-11-28 12:32:21
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => Rob
                    [cognome] => Me
                    [importo] => 129
                    [importomeno] => 
                    [segnomeno] => 
                    [modalita] => contanti
                    [causale] => contrass
                    [dettagli] => Contratto anno 2011 - 2012
                    [data] => 2011-11-15 12:32:07
                    [operazione] => Versamento
                    [input_submit_10] => Invia DATI
                )

            [3] => Array
                (
                    [cf_id] => 5
                    [cf_uid] => a42d5900365f1a8a19c2f8833d1f45f2
                    [cf_created] => 2011-11-28 12:33:20
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => Alex
                    [cognome] => Cot
                    [importo] => 
                    [importomeno] => 59
                    [segnomeno] => -
                    [modalita] => contanti
                    [causale] => rictim
                    [dettagli] => Ricarica cellulare 
                    [data] => 2011-10-13 11:33:06
                    [operazione] => Prelievo
                    [input_submit_10] => Invia DATI
                )

            [4] => Array
                (
                    [cf_id] => 6
                    [cf_uid] => 5999a035a71aa80bacc8c92129209a3d
                    [cf_created] => 2011-11-28 17:42:03
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => lisa
                    [cognome] => lisa
                    [importo] => 
                    [importomeno] => 23
                    [segnomeno] => -
                    [modalita] => Contanti
                    [causale] => Ricarica VODAFONE
                    [dettagli] => ricarica cellulare
                    [data] => 2010-10-11 17:41:52
                    [operazione] => Prelievo
                    [input_submit_10] => Invia DATI
                )

        )

)


now if i try to search nome=lisa and than press TROVA button, i can see this result:

Data Array: 
Array
(
    [nome] => lisa
    [cognome] => 
    [submit] => Trova
    [a2864add6961f9d61c71607ba8a46bff] => 1
    [chronoform] => Primanota_PENNISI
    [Itemid] => 136
    [option] => com_chronoforms
    [view] => form
    [UserDetails] => Array
        (
            [0] => Array
                (
                    [cf_id] => 1
                    [cf_uid] => 4935935850883e1a0cf050967227a696
                    [cf_created] => 2011-11-28 11:55:14
                    [cf_modified] => 
                    [cf_ipaddress] => 213.203.139.182
                    [cf_user_id] => 0
                    [nome] => Ale
                    [cognome] => Cot .... ( all the previus results )


So, i think searching works, but why i see printing always ( and only ) the table with all results and not the result of the searching ?

You can see this work here: http://umbynet.altervista.org/portale/prima-nota
GreyHead 21 Dec, 2011
Hi ciconet,

You need the Site Debug on to see the MySQL queries.

The layout problem looks as though you have the sequence wrong in the On Load box. The results table header is showing after the main body of the results.



Bob
ciconet 21 Dec, 2011
Hello Bob,

if i write into the Form Setting this manual value:

Submit URL: index.php?option=com_chronoforms&chronoform=Primanota_PENNISI&UserDetails=lisa

when i push on TROVA, the result was displayed correctly with only lisa data.

Now, how can i do for replace lisa and get the field NOME and / or COGNOME got on the searching form ?

index.php?option=com_chronoforms&chronoform=Primanota_PENNISI&UserDetails=here ?

And this way is correct for fixing of the searching form ?

Thanks so much

Alex
GreyHead 21 Dec, 2011
Hi ciconet,

In the URL you have UserDetails=lisa, and in the WHERE box you use $form->data['UserDetails'] but in the form you have 'nome' and 'cognome' as the input names.

Bob
ciconet 21 Dec, 2011
hi Bob,

yes i use UserDetails=lisa ( forced ) for try function.

In the WHERE box now i correct in this way:

`nome` LIKE '%<?php echo $form->data['nome']; ?>%' OR `cognome` LIKE '%<?php echo $form->data['cognome']; ?>%'

- ['nome'] is the real first field of the searching form;
- ['cognome'] is the real second field of the searching form;

It is correct ?

But what i have to put into the Submit URL value ?

index.php?option=com_chronoforms&chronoform=Primanota_PENNISI&UserDetails=here ?
GreyHead 21 Dec, 2011
Hi ciconet,

If you are using the form results then you don't need anything in the URL.

Bob
ciconet 29 Dec, 2011
There are other suggestions ?

Or i have to discard it ???
GreyHead 29 Dec, 2011
Hi ciconet,

Here's the query from your page
SELECT `cerca`.*
  FROM `avjos16_chronoforms_data_Cassa` AS `cerca`
  WHERE `nome` LIKE '%lisa%' OR `cognome` LIKE '%%'

As far as I can see you are getting the correct results. `cognome` LIKE '%%' will always be true and so you get all the records.

Bob
ciconet 02 Jan, 2012
Hello Bob,

ok yes i agree. But why this form work in this way ?
I've put `nome` LIKE '%lisa%' OR `cognome` LIKE '%%'
i don't use AND.

I thought the form can work only by nome ( or part of it ) or only by cognome ( or part of it ). This means that entered "lis" or "li" into nome field, and no value into cognome field,the result should be only lisa.

Where i'm wrong ?
GreyHead 03 Jan, 2012
Hi cicone,

Yes, that's correct. You have: "Do 'this' if A is true OR B is true"

But with your code B is always true so MySQL always does 'this'.

If you look at `cognome` LIKE '%%' - the % is a wildcard so it will match any entry in the cognome column including a blank entry.

Bob
Max_admin 03 Jan, 2012
The best way to solve this is to have this code in the WHERE box:


<?php if(isset($form->data['cognome']) && !empty($form->data['cognome'])): ?> OR `cognome` LIKE '%<?php echo $form->data['cognome']; ?>%'<?php endif; ?>


This way you will not have the extra part which breaks it.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
BionicNelly 12 Apr, 2013
Max,

I used the above and it does not work so omitted it and the sql query of LIKE works.

BionicNelly
This topic is locked and no more replies can be posted.