This topic is locked
[SOLVED]

 chart before SQL query

5/2/2012 6:16:48 PM
PHPRunner General questions
S
stiven author

Hello Everyone,
I hope someone can help me here.
I have a chart and I am trying to add a WHERE clause in the Before SQL Query events page but for some reason it is not working for me. I added two inputs in the htm page so that the user can enter a date range to filter the results with the where clause but for some reason i can not get the range date from the user. i have a form and i tried with POST, GET and REQUEST and none of them worked. here is the code hopefully someone can help me



//code on html page
<FORM method=get name=sub_date

action="">

<TABLE style="WIDTH: 735px; HEIGHT: 40px" border=1 cellSpacing=1

cellPadding=1 width=735>

<TBODY>

<TR>

<TD style="WIDTH: 668px" colspane="2"><B><FONT size=2

face=Arial>Select Date range</FONT></B>&nbsp;&nbsp;&nbsp; <INPUT

id=start_date onclick="scwShow (scwID('start_date'), event);"

name=start_date> <IMG onclick="scwShow (scwID('start_date'), event);" alt=calendar src="images/cal.gif" width=16 height=16>&nbsp;<FONT size=2

face=Arial><B>to </B></FONT><INPUT id=end_date

onclick="scwShow (scwID('end_date'), event);" name=end_date> <IMG onclick="scwShow (scwID('end_date'), event);" alt=calendar src="images/cal.gif" width=16 height=16> &nbsp;<INPUT name=submitted

value=1 type=hidden>&nbsp;<INPUT name=submit value=Submit type=submit></TD></TR></TBODY></TABLE></FORM>
//code on the events page
if($_GET['submit'] == 'Submit'){
$arr_one = explode("/",$_GET['start_date']);

$arr_two = explode("/",$_GET['end_date']);
$start_date = $arr_one[2]."-".$arr_one[0]."-".$arr_one[1];

$end_date = $arr_two[2]."-".$arr_two[0]."-".$arr_two[1];

}

else{
$start_date = date('Y-m')."-01";

$end_date = date('Y-m-d');

}
$strWhereClause = whereAdd($strWhereClause, "expedientes.date_added BETWEEN '".$start_date."' AND '".$end_date."'");


it always shows the current month even after submitting the range date.. and the values are going through because i can see them on the URL
Cask__Amount_chart.php?start_date=04%2F01%2F2012&end_date=04%2F30%2F2012&submitted=1&submit=Submit
Thanks for your help

C
cgphp 5/2/2012
if($_GET['submit'] == 'Submit')

{
$start = str_replace("%2F","/",$_GET['start_date']);

$end = str_replace("%2F","/",$_GET['end_date']);
$arr_one = explode("/",$start);

$arr_two = explode("/",$end);
$start_date = $arr_one[2]."-".$arr_one[0]."-".$arr_one[1];

$end_date = $arr_two[2]."-".$arr_two[0]."-".$arr_two[1];

}

else{
$start_date = date('Y-m')."-01";

$end_date = date('Y-m-d');

}
Sergey Kornilov admin 5/2/2012

I'm not sure why would you need to build your own form when you can use chart Advanced Search page or search panel. Even if this method doesn't produce desirable results you can study parameters passed via URL and mimic this behaviour.

S
stiven author 5/2/2012

@Cristian
Thanks for your help unfortunately this didn't work it is still showing all the results it does not do the filter
@admin
I'm not sure how the search works here, I tried adding the field date_added to the search but when i tried the search panel and advance search the result is the same it does not filter anything it keeps giving me all the results.

Sergey Kornilov admin 5/2/2012

I guess this some sort of issue with setup, hard to tell based on this info.
I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.
Another thing to try - print generated SQL query on the page:

http://xlinesoft.com/phprunner/docs/debugging_tips.htm
This may suggest why filtering is not working.
PS. Make sure you do not have any code in BeforeSQLQuery event that may interfere with built-in search.

S
stiven author 5/2/2012

I found the solutions here
http://www.asprunner.com/forums/topic/8044-get-not-available/
I had to use sessions..
thanks.