944,149 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 352
  • PHP RSS
Nov 6th, 2009
0

Filtering categories

Expand Post »
How can we filter categories (checkbox) like this: http://tp.jobscentral.com.sg/pubsearchjobs.php
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xueping is offline Offline
3 posts
since Nov 2009
Nov 6th, 2009
-1
Re: Filtering categories
Have you checked the view-source?
They use the same name for all checkboxes and apply a numerical value to each based on the 'id' of the category in the DB.
So the $_POST['categories'] variable will contain an array of values. You then need to either loop through this array OR create a comma separated list from this array to use in your SQL statement (hint - you'll need to use the IN keyword in the WHERE clause).
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006
Nov 11th, 2009
0

New problem faced.

thanks for your help ardav. greatly appreciated (:
i encounter another problem. now my job posting system can only post 1 job for a user. any idea what's the problem or any suggestions?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xueping is offline Offline
3 posts
since Nov 2009
Nov 11th, 2009
-1
Re: Filtering categories
Where is the problem? With the post variable or with your database field?

Your DB should have a structure something like:

user
id (PK)
username
...etc...

jobs
id (PK)
job_title

user_jobs
id (PK)
user_id (Foreign Key on user.id)
job_id (Foreign Key on jobs.id)

(This last table could be v.big, but that's OK, e.g. 30 jobs for each user. Even if you've got 10,000 users, that's still only 300,000 records - nothing for mysql)
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Global Class Variables.
Next Thread in PHP Forum Timeline: Dropdown menu with multiple values





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC