Search when opening a form.

Questions related to customising nuBuilder Forte with JavaScript or PHP.

Re: Search when opening a form.

Unread postby kknm » Sat Apr 24, 2021 12:30 am

kev1n wrote:Should the form display all records when opened? Then you would this "OR LOCATE( ..." condition in your where clause that I posted earlier.

Initially, it should open - the current month, and by buttons - the current year and return to the current month.
kknm
 
Posts: 231
Joined: Sat Apr 11, 2020 7:33 am

Re: Search when opening a form.

Unread postby kev1n » Sat Apr 24, 2021 12:52 am

When the form is first opened the Hash Cookie #year_filter#' doesn't exist and hence will not be replaced with its value.
Therefore if your WHERE clause looks like this

Code: Select all
WHERE
    (( DATE_FORMAT(p_dat,'%Y-%m')  LIKE '#year_filter#'))


you will have to change it to something like this:

Code: Select all
WHERE
(
   ( LOCATE('#', '#year_filter#') = 1
     AND YEAR(your_date_column) = YEAR(CURDATE())
     and MONTH(your_date_column) = MONTH(CURDATE())
    ) OR
    (
      DATE_FORMAT(p_dat,'%Y-%m') LIKE '#year_filter#'
    )
)
kev1n
nuBuilder Team
 
Posts: 2059
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Previous

Return to Custom Code

Who is online

Users browsing this forum: No registered users and 4 guests