By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

how to check out if a checkbox has been checked?

P: 10
Dear all,

I am doing a search engine, and I have a problem, I need to check which of the checkboxes has been checked. According to the checkbox checked, the search engine will search a specific content of a field of my database.
But the script I wrote doesn´t work.


Expand|Select|Wrap|Line Numbers
  1. $request="select * from tablabu where (";
  2. if ($_POST['Picture'] == "on"){
  3.  {$request=$request." `tablabu`.`Kind_of_document`  LIKE 'PI') OR (";  }
  4.  if ($_POST['Video'] == "on"){
  5.  {$request=$request." `tablabu`.`Kind_of_document`  LIKE 'VI') ;OR ("; } 
  6. ETC...
Thanks a lot for your help
Jul 5 '07 #1
Share this Question
Share on Google+
3 Replies


epots9
Expert 100+
P: 1,351
Dear all,

I am doing a search engine, and I have a problem, I need to check which of the checkboxes has been checked. According to the checkbox checked, the search engine will search a specific content of a field of my database.
But the script I wrote doesn´t work.


$request="select * from tablabu where (";
if ($_POST['Picture'] == "on"){
{$request=$request." `tablabu`.`Kind_of_document` LIKE 'PI') OR ("; }
if ($_POST['Video'] == "on"){
{$request=$request." `tablabu`.`Kind_of_document` LIKE 'VI') ;OR ("; }
ETC...

Thanks a lot for your help
I think this is what your looking for
set up your html like this:
[HTML]
<input type="check" name="Picture" id="Picture" value="1" />
<input type="check" name="Video" id="Video" value="1" />
[/HTML]

then
[PHP]
if ($_POST['Picture'] == "1")
{
//code
}
if ($_POST['Video'] == "1")
{
//code
}
[/PHP]

good luck
Jul 5 '07 #2

pbmods
Expert 5K+
P: 5,821
Raphaelle, please use [code] tags when you post source code.
Jul 5 '07 #3

ak1dnar
Expert 100+
P: 1,584
Dear all,

I am doing a search engine, and I have a problem, I need to check which of the checkboxes has been checked. According to the checkbox checked, the search engine will search a specific content of a field of my database.
But the script I wrote doesn´t work.


Expand|Select|Wrap|Line Numbers
  1. $request="select * from tablabu where (";
  2. if ($_POST['Picture'] == "on"){
  3. {$request=$request." `tablabu`.`Kind_of_document` LIKE 'PI') OR ("; }
  4. if ($_POST['Video'] == "on"){
  5. {$request=$request." `tablabu`.`Kind_of_document` LIKE 'VI') ;OR ("; } 
  6. ETC...
Thanks a lot for your help
hi,
There is ETC in your coding so that means there are lots of checkboxes in your HTML FROM isn't it?

Could you please post the coding for the
  1. HTML form structure
  2. Table Structure
  3. and the Query string that you hope to use with.
Thanks!
Jul 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.