php/mysql show data from chosen checkboxes

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2011-01-12T13:41:17Z Indexed on 2011/01/12 13:54 UTC
Read the original article Hit count: 259

Filed under:
|
|
|

Hi.

I have a table called FRUIT

id  type    daysold
1   banana  5
2   apple   6
3   apple   4
4   peach   2
5   banana  6

What I would like is to have 3 checkboxes:
Banana [ ]
Apple [ ]
Peach [ ]
SUBMIT

Then if I've only checked "Banana" and "Peach" the mysql output should only show me the rows that matches those two types. And the checkboxes should remain checked to highlight what was chosen.

I can make the checkboxes but then that's about it really. I don't know how to properly get the info from the checkboxes and down to the WHERE argument in the MYSQL-code. Especially not with two types chosen.

If it was just a dropdown menu with a single choice then I'd add the choice to the url and put WHERE type='$choice' - but I'm struggling with the multiple choices.

I'm a bit of a novice at both php and mysql, so I'm a bit lost on this one.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql