Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Search when opening a form.

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: Search when opening a form.

Unread post by kknm »

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.
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Search when opening a form.

Unread post by kev1n »

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#'
	 )
 )
Post Reply