Filtering categories

Reply

Join Date: Nov 2009
Posts: 3
Reputation: xueping is an unknown quantity at this point 
Solved Threads: 0
xueping xueping is offline Offline
Newbie Poster

Filtering categories

 
0
  #1
23 Days Ago
How can we filter categories (checkbox) like this: http://tp.jobscentral.com.sg/pubsearchjobs.php
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 959
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 126
ardav's Avatar
ardav ardav is offline Offline
Posting Shark
 
0
  #2
23 Days Ago
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).
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: xueping is an unknown quantity at this point 
Solved Threads: 0
xueping xueping is offline Offline
Newbie Poster

New problem faced.

 
0
  #3
18 Days Ago
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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 959
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 126
ardav's Avatar
ardav ardav is offline Offline
Posting Shark
 
0
  #4
17 Days Ago
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)
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC