Jump to content

Search Checkbox Noob Problem

El Chupacodra

Recommended Posts

Hi gang, new to posting but I've read the forum on and off.


I'm coding a small community and will have a lot of questions for you over time.

The first one is about a search function.


We'll have users of different nationalities and languages and you will be able to search, only I was thinking there could be a better way.

They'll enter those posts through a dropdown list and when you search it you will use checkboxes.

I just don't see the results I want when I pick the array for info.


Like I have this right now as the form (which is sent to the php page itself as POST):

Nationality: <br />

<input type="checkbox"" name="natBox[]" size="30" value="all"/> All<br />

<input type="checkbox"" name="natBox[]" size="30" value="weuro"/> W Europe<br />

<input type="checkbox"" name="natBox[]" size="30" value="eeuro"/> E Europe<br />

<input type="checkbox"" name="natBox[]" size="30" value="wafrica"/> W Africa<br />


And the thing I was doing was to check the boxes with if (isset) and then make the query longer and longer, butI figure there could be a smarter way.

Like if I was going to enter 200 countries I can't really check for all can I?


After the check (now deleted) it sets the query to this:


$query = "SELECT * FROM user_criteria WHERE (age BETWEEN '$ageFr' AND '$ageTo') AND nationality='$nationality'";


...and the part I don't have now is to pick the array natBox and add every value so @nationality becomes for instance weuro OR wafrica etc.


Got a more elegant approach?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.