Forums

form that extracts data from the database between two dates of two fields of research

pieroso 18 Feb, 2014
Hello everyone , I use chronoform 4.0 RC3.21 with joomla 1.5.26 , I have a form that extracts from a table with a field " insert_date " records that have the value of this field within two dates entered by the user into two camps: ( start_date and end_date ) .
I've already made other functional forms that extract data say " onload " but now I can not find the solution. However, for this form I proceeded as follows:

I put two fields "datetime box" and a "submit bottom" in the " preview" ;
in the " events" :
in " onload " I put a "show html" ;
"On Submit" use "DB Multi Record Loader" that I set up like this:
in "Table" connecting my table ,
in " Model- id" write " list "
in "WHERE statement" the code:
insert_date between <? php echo JRequest :: getInt ( ' start_date ' ) ; ? > AND <? php echo JRequest :: getInt ( ' end_date ' ) ; ? >

in " Enable Data Displayer " selected " yes"
in the "Display Fields " field and insert_date amount .
I have included a ' custom code ' in ' on record found' with the code:
<ul>
<? php foreach ( $ form -> data [ ' list ' ] as $ r) : ? >
<li> <? php echo $ r [ ' insert_date ' ] . " ' . $ r [ ' amount ' ] ; ? > </ li>
<? php endforeach ; ? >
</ ul>
Having selected the Enable Data Displayer yes , I also tried without this code, but I could not render any data.

I sincerely hope that someone help me, I do not know what to do.

thanks
Piero .
GreyHead 19 Feb, 2014
Hi Piero,

I think that your dates probably are strings and not integers and you are missing quotes round the dates:
<?php
$start_date = JRequest::getString('start_date');
$end_date = JRequest::getString('end_date');
echo " `insert_date` BETWEEN '{$start_date}' AND '{$end_date}' ";
?>

Bob
pieroso 19 Feb, 2014
You're great, it works! 😀
I have to improve my php.
Thank you very much, When I finish this site thank you best

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