# Checkbox array and mysql

**URL:** <https://forum.kirupa.com/t/checkbox-array-and-mysql/271189>\
**Category:** Uncategorized\
**Created:** [September 19, 2008, 3:26pm UTC](https://forum.kirupa.com/t/checkbox-array-and-mysql/271189 "2008-09-19T15:26:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patch](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/patch/32/1095_2.png) [@Patch](https://forum.kirupa.com/u/Patch)\
**Post date:** [September 19, 2008, 3:26pm UTC](https://forum.kirupa.com/t/checkbox-array-and-mysql/271189/1 "2008-09-19T15:26:48Z")

</div>

Howdy!

I need a little help in creating a query for a small search engine for a site I am working on. I have a form that I get my values from. It includes some parameters that will effect the result of my query and I’m a little unsure on how to do it.

I know how to do a basic query i.e.

```php

$sql = "SELECT * FROM jobs WHERE job_title LIKE \"%$_POST['search']%\"";

```

Even though the above example uses wildcard, it works ok if you are querying one column.

However, I have to make a form that uses checkboxes and other inputs that add to the query and search different columns.

Obviously I’ll need an array something like this:  
\<input type=“checkbox” name=“sector[]” /\>

The problem I’m having is adding the checkbox into my query, I’ve noticed that it just adds the last checked value.

I guess I need a foreach loop and conditional statement which adds and breaks up the array into my query.

I’ve been trying to do this for a few hours now, if anyone has any experiance with something I have mentioned could you show me a example or point me in the right direction?

Cheers! 🙂
