Passing variables to a query

I have a dropdown menu with different items. Let's call them Pink, Green, and Red.

I can store the selected menu item in a variable (e.g., red).

How can I pass this variable, "red," to a query so that it returns all the red items but not the pink and green ones?

Thank’s in advance

are you submitting your data through a form? You wouldn’t need a variable, your select drop down should have value for each drop down item. then you will send to your server connect through $_POST variables. Then in your query at the server connect you will just set a condition for that variable being passed. At the top of your server connect you can click on input, then you choose the page and the form name and it will auto import your form names. easy peazy. if you post a pic of your server connect I can fine tune it for you.

Yes I use a form. Is the screenshot that one you need?

show one shot with your variables that you are importing, ie click on the inputs and show what is there. And then submit another picture with your actual database query and what the condition is on that

I do not have very much experience with the app. Hope this is the right screen

well if you are using a form you should be using $_POST variables.

And then open your query and show the condition it is filtering on

I’m really sorry for that circumstances. But I can’t follow your instructions. Is there any picture by picture tutorial? I don’t know where I have to put the $_Post in

start by clicking on the drop down and pick your form and then click import from form. this will add your $_POST variables. Then in your database query set the condition to the variable you want to filter by

Thanks. But the list is empty. And by importing: No form fields found

if no form fields are showing up, are you sure you added a form? the form needs to be set to server connect form too. there should be a drop down for that.

And there should be an actual form on your page, not just a select field.

I used the dropdown

post your code of the form. There should be a form, and then a select should be under that form. Form should be set to server connect which should auto switch the type from GET to POST.

Your code should look something like this:

<form id="yourformname" is="dmx-serverconnect-form" method="post" action="/dmxConnect/api/Colors/delPaddingColor.asp">
<select id="select1" class="form-control">
  <option value="1">Option One</option>
  <option value="2">Option Two</option>
  <option value="3">Option Three</option>
</select>
</form>

I didn't link the menu items to the options; instead, I read them from a different data table.

You are not actually using a form, POST variables are only used when you actually submit a form.
All you need is

  1. Create a GET variable in your server action, for example $_GET.filter:

  2. Use this GET variable in the query builder to filter the data with the condition you need (equals/contains etc.):

  3. On the front end, add your server action and you will see the GET variable:

  4. Assign a value to it, the value should be your select value:

When the value changes in the select, the data will update automatically. That's it, pretty straightforward.

If I understand correctly, in the first query for countries, I need to set a $_Get variable to store the country. Then, in the second query, which, for example, sorts the images by country, I need to use that variable as a condition.

Is that right?

I am not sure i understand what you mean?
You need to use the get variable in the filters for the query which you want to filter, as shown on my screenshot.

I have two queries and two Tables:

  1. List all countries from the table in the dropdown menu. After clicking on a specific country, store this information in a variable that I need in the second query.

The second query should load images of the country.

How are the two tables related exactly?