Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass multiple values of a variable through a URL

I've an application that I'm building, and I'm stuck at a certain point.

I'm trying to pass a variable that has multiple values. So my URL will look like:

localhost/report.php?variable=value1, value2, value3

Problem is I'm not sure how I can do this. The variables are to be used to retrieve data from a database. I'm using PHP and no Javascript.

Any help would be great!

EDIT:
Here is the HTML I have in my page where the variables are selected:

<select name="types" size="19" multiple>
    <option value="all" selected>All Types</option>
    <option value="book" selected>Books</option>
    <option value="cd" selected>CD</option>
</select>

So a user could select Books and CD, and I would need to pass these two values in the "types" variable.

like image 317
mickburkejnr Avatar asked Aug 12 '12 19:08

mickburkejnr


People also ask

How pass multiple query parameters in URL in PHP?

How pass multiple query parameters in URL in PHP? To pass multiple parameters, we will use the “&” symbol to separate the other field and value combinations.

How pass multiple parameters in URL in asp net?

To pass multiple parameters, we will use “&” symbol to separate the other field and value combinations. On button click (from code behind), redirect to another page with two QueryString parameters. Now this example has two parameters or variables. The first is the userid=43 and second is the contentid=9 respectively.

Can a get request have multiple parameters?

You have multiple options for passing multiple parameters to a GET method: FromRouteAttribute, FromQuery and Model Binding.It gets the data from various sources in the form of key-value pairs from the following sources: Form fields. Request body. Route data parameters.


1 Answers

Use &

localhost/report.php?variable=value1&val2=value2&val3=value3

Is that what you are after?

like image 190
jp2code Avatar answered Sep 27 '22 16:09

jp2code