Problem filtering dataset with URL parameter

I hope someone can tell me what I am either doing wrong or have failed to do properly.

I am using PHP with a MySql db. I am trying to build an order system where a page brings back all of the orders and then when you click on a link takes you to another page where you see the details for the order.

The orders page passes the unique order id to the details page via a URL parameter. I have set up the query in the API with a where clause. Set a parameter, expression and default value and when it runs it brings back the correct record. The custom query name is orderdetails and the Step name under API is Order_Details.

On the order details page (OrderDetails.php) I have an App with ID OrderDetails where I defined a Query Param titled idOrders. I have a Server Connect titled scOrderDetails whose Server Action references Order_Details. I also have a variable titled getorderid.

When I pass the URL parameter from the Orders page to the OrderDetails page it comes through and I can both see it in the URL and write it to the page as text using query.idorders. But I can’t get the db results.

I see the data structure when I try to add a field to a bootstrap card but nothing shows. I’ve set the SC Input Parametes to the variable getorderid but nothing comes back. I even tried hard coding in the query.idorders URL param but nothing. I’ve set the expression in the API Step Order_Details to (enclosed in the correct double brackets): $_GET.getorderid.

I have read every How To and post and watched videos and for the life of me I can’t figure out where I am going wrong. No doubt it is something obvious and I am just too clueless to notice, but if someone could help me with this I would be forever grateful.

It’s hard to say without seeing screenshots and/or code but some things to check are…

  • case-sensitive GET var
  • check the dev console to see if the data is coming back from the API
  • using Security Provider which might be blocking it

Set the actions in the API to output and browse to it directly using the icon at the top right:

Screenshot 2023-02-27 at 18.43.54

and make sure to add ?getorderid=1234 (1234 = whatever ID will pull data from the database).

As an aside, don’t have it so the only variable is the ID (especially if it’s an autoincrement field) as that would be very insecure. Either add another field to hold a value (like a random code) and pass that, too (eg. ?getorderid=1234&code=fye73hd6) or use a UUID field and set your WHERE clause to use that.

Thanks for getting back to me sitestreet. A couple questions about your answers. Where is the dev console you are referring to? I looked for it on the Wappler Docs page that lists the User Interface but don’t see a reference. Also, I did create a Security Provider though I have not had an opportunity to dig into this. Is it something that get invoked on the page? How do I know if it is the problem? Also, I can’t find an Output setting in the API all I see in Input. Where is that accessed?

I believe this is referring to a browsers dev console normally right click in a browser and inspect or inspect element can open this, this tutorial shows the console in the second half:

Oh, yes. I do that in Chrome. Developer Tools. Had tried that. The problem appears to have been a case sensitive issue. Everything seems to be working now. Thanks.

Comforting to hear that was the first thing I thought it might be :blush:. Glad you’re sorted.

1 Like