Hi,
I have several categories in my DB each with an ID number.
Using a DB query how can I show the results of a combination of categories using a URL parameter request?
Example would be;
www.domain.com/category.php?cat_id=1&cat_id=2&cat_id=3
Do I need to use the multiple check box on the $_Get filter?
Many thanks
CK
Teodor
June 17, 2022, 9:46am
2
Which part is not clear for you - how to add the filters in the url or how to filter the database query using the filters in the url?
I think the URL string is correct so I need to know how my database query should look in order for this to work.
Teodor
June 17, 2022, 10:36am
4
Well, you need to define GET variable per each URL param and pass its value to the filters in the query builder, depending on your needs. It follows the same logic https://docs.wappler.io/t/filtering-database-query-with-an-url-parameter/2868
I see, I thought there might be a way to make the DB query accept multiple URL inputs to just a single filter.
I may as well just create a query with all the categories I need and not bother with the URL parameters.
I was looking for something more dynamic…
Teodor
June 17, 2022, 10:59am
6
Well if you want to use a single url param with multiple values, then just use it like:
www.domain.com/category.php?cat_id=1,2,3
and split its value on the server side, to receive an array with the cat_id
to be used in the filters.
Can you suggest a tutorial on how to;
‘split its value on the server side, to receive an array with the cat_id to be used in the filters’
Teodor
June 17, 2022, 12:36pm
8
Just apply the split formatter to the &_GET.param_name when used in the filters.
Use a checkbox array and a SQL IN clause in your SELECT query
Tried your split value suggestion but get no result. When I inspect the page I have an error:
Failed to load resource: the server responded with a status of 404 ()
https://mydomain.com/dmxConnect/api/Categories/CategoriesAllBindery.php?cat_id=1%2C2
URL was https://mydomain/dmxConnect/api/Categories/CategoriesAllBindery.php?cat_id=1,2
The split code looks like this:
$_GET.cat_id.split(’,’)
Teodor
June 18, 2022, 1:55pm
11
The 404 error means the file is missing from your server.
franse
June 18, 2022, 8:28pm
12
My easy way is check what is missing. You should find in your chrome dev tools, 2 buttons for warning and alert, the red one tells you what is missing.
I reccomend you to reupload the file.
Re-published my site and I now get the following error;
Failed to load resource: the server responded with a status of 500 ()
https://mydomain.com/dmxConnect/api/Categories/CategoriesAllBindery.php?cat_id=1
If I follow the link above the page loads with the following error;
A server error occurred, to see the error enable the DEBUG flag.
If I enable Debug on the DB query the original page;
https://mydomain.com/category-all-bindery.php?cat_id=1
loads but with just three blank records. If I load the api page I get a page thats loads what looks like JSON info.
Teodor
June 19, 2022, 9:57am
15
You should not enable the debug option on the query step! This should be off.
You need to enable this:
You can easily debug issues related to server-side processing such as - form not sending email, record not inserting or updating, query not showing data etc.
The first thing you need to do is to open the server connect settings. They are located in the Workflows Panel > Server Actions:
[Screenshot 2021-09-27 at 10.02.35]
And enable the Debug Mode:
[Screenshot 2021-09-27 at 10.03.08]
Click Save:
[Screenshot 2021-09-27 at 10.03.26]
In your browser, open the Developer tools. If you don’t k…
1 Like
OK, thank you
Have turned on the debug and get the following error in the inspect tab:
Failed to load resource: the server responded with a status of 500 ()
https://mydomain.com/dmxConnect/api/Categories/CategoriesAllBindery.php?cat_id=1%2C2
That page now shows;
// 20220620092124
// https://mydomain.com/dmxConnect/api/Categories/CategoriesAllBindery.php?cat_id=1%2C2
{
“code”: 0,
“file”: “/var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/db/Connection.php”,
“line”: 141,
“message”: “Array to string conversion”,
“trace”: “#0 [internal function]: exception_error_handler(8, ‘Array to string…’, ‘/var/www/vhosts…’, 141, Array)\n#1 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/db/Connection.php(141): PDOStatement->bindParam(2, ‘Array’, 2)\n#2 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/modules/dbconnector.php(93): lib\db\Connection->execute(‘SELECT * FROM `…’, Array, true, ‘’, Array)\n#3 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/App.php(197): modules\dbconnector->select(Object(stdClass), ‘query’, Array)\n#4 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/App.php(137): lib\App->execSteps(Object(stdClass))\n#5 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/App.php(126): lib\App->exec(Object(stdClass), false)\n#6 /var/www/vhosts/mydomain.com/httpdocs/dmxConnectLib/lib/App.php(104): lib\App->exec(Object(stdClass))\n#7 /var/www/vhosts/mydomain.com/httpdocs/dmxConnect/api/Categories/CategoriesAllBindery.php(8): lib\App->define(Object(stdClass))\n#8 {main}”
}
Teodor
June 20, 2022, 8:38am
17
Post some screenshots of the query setup please.
Teodor
June 20, 2022, 9:12am
19
With the split value you need to use IN, not Equal.
Brilliant, worked first time - of course.
Thank you @Teodor once again.