Hi

i have a form which is used to post jobs.
i have multiple checkboxs for location's i need a way in which i can save all the values which are checked into single table or two .

right now i have a table called jobs in which all the jobs ad's will be added.

i need a way which can also help me to create search option as well.

if i create one field in job table called location and save all the check values in it like 1,3,4 then how i create a search query ...

Users are only allowed to select one option, Right? if so, then it's easy.

<form action= ""  method="POST"> 

Your checkboxes go here. Users are allowed to choose one option of a few you have given them.
</form>


Inside your action, you put the page that does insertion into your DB.

If this is unclear, please post your code.

Personally I would use two tables if you want to be able to easily search. So have your main jobs table and then a second that stores all locations per job (just store job_id and location_id and ensure you can store the job_id multiple times) then you can search this table based on location and grab all the job adverts specific to the location from the main jobs table.

If you store all the locations in one column in your jobs table you will have to serialize the data and then it becomes difficult to search using a query, you would have to grab all data first, unserialize it and then see if the location is in the data.

Personally I would use two tables if you want to be able to easily search. So have your main jobs table and then a second that stores all locations per job (just store job_id and location_id and ensure you can store the job_id multiple times) then you can search this table based on location and grab all the job adverts specific to the location from the main jobs table.

If you store all the locations in one column in your jobs table you will have to serialize the data and then it becomes difficult to search using a query, you would have to grab all data first, unserialize it and then see if the location is in the data.

Member Avatar for diafol

DO you have any code of your own to share?
E.g. forms, table structures, sqls ?

Whistling in the dark here mate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.