This topic is locked

Dropdown with Month to select Period

11/13/2007 5:59:56 AM
PHPRunner General questions
W
webdino author

How can I insert a Dropdown Menue and Year Field to select different data from this period an display it to the user after he has taken a selection?

The Field in the database is a timestamp field and should asked like select ...... where date between 1111 and 2222 (created Timestamps from selection)
Thank you for help.

Alexey admin 11/13/2007

Hi,
I wasn't able to understand what are you trying to do.

Provide a more detailed description of your task.

Alexey admin 11/13/2007

Hi,
I wasn't able to understand what are you trying to do.

Provide a more detailed description of your task.

W
webdino author 11/13/2007

Hi,

I wasn't able to understand what are you trying to do.

Provide a more detailed description of your task.


The User must select the period for example January 2007

then the Date must konvert into a Timestamp with my own function and the SQL select musst integrate this Variable
This variable ist dynamic to select from the user after this a report should be shown with this data.

For example:

without any selection before the user has selected->

SQL: Select Menge, Datum, Einheit from Buchungen
User has selected 01/2007->

SQL: Select Menge, Datum, Einheit from Buchungen where Datum between gmt_to_cet('01.01.2007') and gmt_to_cet('31.01.2007').
This Range musst be insert dynamic into the standard SQL.

W
webdino author 11/14/2007

is there a solution for this problem or doesn´t it work with PHPR?

W
webdino author 11/15/2007

ist it possible to generate a dynamic date in the where clause of the query?
when it ist posiible how is this to realize?

thanks for answers

Alexey admin 11/15/2007

Hi,
you can do this using Visual Editor and Before SQL queryevent.

Add this code to the List page with Visual Editor (in HTML mode):

<select onchange="window.location='..._list.php?a=filter&'+this.options[this.selectedIndex].value">

<option value="from=2007-11-01&to=2007-12-01">November 2007</option>

<option value="from=2007-12-01&to=2008-01-01">December 2007</option>

...

</select>



Then put this code to Before SQL query event:

if($_GET["a"]=="filter")

$strWhereClause=whereAdd($strWhereClause,"Datum between '".$_GET["from"]."' and '".$_GET["to"]."'");

W
webdino author 11/15/2007

thank you i will try it

M
mrpeeble 7/7/2008

Hi,

you can do this using Visual Editor and Before SQL queryevent.

Add this code to the List page with Visual Editor (in HTML mode):
Then put this code to Before SQL query event:


Hi ,

The above code works great, the list page jumps to the selected month as per the selected value in the combo box. What I cant figure out is how to show the selected month in the combo control after the filter is applied to the list page. The combo always goes back to show Select Month after the filter is applied. Any help would be appreciated. thanks.
I added the following with visual editor:
<select onchange="window.location='SDP_Monthly_Payment_Review_list.php?a=filter&'+this.options[this.selectedIndex].value">

<option value="Please select...">Select Month</option>

<option value="from=2008-3-01&to=2108-04-01">All Months</option>

<option value="from=2008-3-01&to=2008-04-01">March 2008</option>

<option value="from=2008-04-01&to=2008-05-01">April 2008</option>

</select>

J
Jane 7/8/2008

Hi,
I recommend you to use custom event (Insert PHP code snippet option on the Visual Editor tab) for this dropdown.

Here is a sample:

$str = "";

$str.= "<select onchange=\"window.location='SDP_Monthly_Payment_Review_list.php?a=filter&'+this.options[this.selectedIndex].value\">";

$str.= "<option value=\"Please select...\">Select Month</option>";
if ($_GET["from"]=="2008-3-01" && $_GET["to"]=="2108-04-01")

$str.= "<option selected value=\"from=2008-3-01&to=2108-04-01\">All Months</option>";

else

$str.= "<option value=\"from=2008-3-01&to=2108-04-01\">All Months</option>";
$str.= "<option value=\"from=2008-3-01&to=2008-04-01\">March 2008</option>";

$str.= "<option value=\"from=2008-04-01&to=2008-05-01\">April 2008</option>";

$str.= "</select>";
echo $str;

M
mrpeeble 7/9/2008

Hi,

I recommend you to use custom event (Insert PHP code snippet option on the Visual Editor tab) for this dropdown.

Here is a sample:


Hi Jane,
I had tried something similar previously and it did not work. I then tried the exact code you recommended in the custom event along with the BeforeQuestList and htm code and it does not appear to work either. The combo box sets the filter for the list page properly but does not reflect the filter selected, it always goes back to 'Please Select'. Here is the code I am using, perhaps it is something small:
function BeforeQueryList(&$strSQL,&$strWhereClause,&$strOrderBy)

{
if($_GET["a"]=="filter")

$strWhereClause=whereAdd($strWhereClause,"ReportMonth between '".$_GET["from"]."' and '".$_GET["to"]."'");
} // function BeforeQueryList
function SDP_Monthly_Payment_Review_Event1(&$params)

{

// Put your code here.

//echo "Your message";

$str = "";

$str.= "<select onchange=\"window.location='SDP_Monthly_Payment_Review_list.php?a=filter&'+this.options[this.selectedIndex].value\">";

$str.= "<option value=\"Please select...\">Select Month</option>";
if ($_GET["from"]=="2008-3-01" && $_GET["to"]=="2108-04-01")

$str.= "<option selected value=\"from=2008-3-01&to=2108-04-01\">All Months</option>";

else

$str.= "<option value=\"from=2008-3-01&to=2108-04-01\">All Months</option>";
$str.= "<option value=\"from=2008-3-01&to=2008-04-01\">March 2008</option>";

$str.= "<option value=\"from=2008-04-01&to=2008-05-01\">April 2008</option>";

$str.= "</select>";
echo $str;

}
In the _list.htm:
<select onchange="window.location='SDP_Monthly_Payment_Review_list.php?a=filter&'+this.options[this.selectedIndex].value">

<option value="Please select...">Select Month</option>

<option value="from=2008-3-01&to=2108-04-01">All Months</option>

<option value="from=2008-3-01&to=2008-04-01">March 2008</option>

<option value="from=2008-04-01&to=2008-05-01">April 2008</option>

</select>

J
Jane 7/9/2008

Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

mikue from germany 7/9/2008

Hi Jane,
I have the same problem with very similar code:
The combo box sets the filter for the list page properly but does not reflect the filter selected,

it always goes back to 'Please Select'.



Please publish the solution from forerunner mrpeeble into that thread.
Thanks Michael

J
Jane 7/10/2008

Here is the general solution:

if ($_REQUEST["from"]=="firstvalue" && $_REQUEST["to"]=="secondvalue")

$str.= "<option selected value=\"from=firstvalue&to=secondvalue\">Option1</option>";

else

$str.= "<option value=\"from=firstvalue&to=secondvalue\">Option1</option>";