Filtering Database Query with an URL Parameter

If you don’t know how to define an URL parameter on your page, please check this tutorial as you will need this later.

First, we need to create a server action. Open the server connect panel and click the add new button:

We call it product_details:

Then right click GET under Globals menu:

Add variable:

This variable will be used to filter our database query. Let’s call it: productid (NOTE - it needs to be lowercase).

Right click steps:

Open database actions menu:

Add a database connection:

Load your database connection, or create one if you have not defined one yet. Then right click the database connection step:

Open the database actions menu:

And add database query:

Open the query options:

Add your database table:

Then add the database table columns you need:

Open the conditions tab:

And select the column you want to filter your database query by:

Select the equal operator:

And click the dynamic data picker for the filter value:

Select the GET variable we created - productid:

Then click ok:

Save your server action and close the server connect panel as we won’t need it anymore:

In App Structure define your URL parameter using the query manager:

Then add new component:

Open the data menu:

Select Server Connect:

And click the select server action button:

Select your server action:

Under Input parameters, you will see the GET variable which you defined in the server action. Ours is called productid - click the dynamic data picker to assign a dynamic value to it:

Under query select the URL parameter you defined:

Then on your page, double click where you want to show the dynamic data:

Click the dynamic data picker button:

And select the data you need here, from your server action:

That’s it your data will be filtered using the URL parameter’s value and you will see it on the page.


WapplerPrevious   WapplerNext


1 Like

Hi,
Unless there is a mistake in this slide, I’m lost.
Where does this query / filter data binding come from? Shouldn’t we bind to the URL param defined in query1 instead?

Thx for the speedy reply but I quoted a screenshot where you select a query ‘filter’ created out of the blue, yet you instruct otherwise in the page below: create then select ‘id’ variable of ‘query1’ defined in the Query Manager.


then:

I don’t really understand what your issue / question is.
All you need to do is to define a query parameter under App and select it then in the data picker where needed, under query.

I understand how to define the query param (you define the var as ‘id’).
I don’t understand why you then select ‘filter’ in query instead of ‘id’ inside the Query Manager: query1:

You select the query parameter defined under query, as explained here: https://docs.wappler.io/t/define-url-parameters/2913 ! It doesn’t matter how is it called, it’s you who give a name to it.