I am currently working on a page, where I need to send a query to a MySQL database based on data chosen by the user.
OK, to be more specific. I have a webpage, where the user can select countries. Using javascript I get the countries selected as a string. The countries are abbreviated by their 2-letter code, so I get for example a string "US,GB,AU", which would indicate the user selected US, UK and Australia.
Now, I send this to a PHP page, which gets this using the GET parameter.
So now I have this PHP page, which first obtains the string and then, using the explode function I split it into an array based on the commas, so I have an array containing 3 elements, in this case, US, UK and AU.
And now that part that I don't know how to do. Apart from the country,the user can also select population. This however is simple, because it is always just one number.
What I do then is I want to send a query to the MySQL database, which contains many cities and choose some based on the user selected population and country.
So I have the SQL query and then the crucial bit is the WHERE statement, where I have:
WHERE Population>$population AND Country=
now this is where I don't know how to continue. What I want is to get all the cities from the selected countries. Each city is a row in the database, which contains its name, population and the country code.
If it was just one country it would be simple, it would be the same as for the population, just Country='$country', but how do I make it so that it chooses all the cities which correspond to any of the user selected values, stored in the array.
Thanks