how to check out if a checkbox has been checked?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Phaelle
    New Member
    • Jun 2007
    • 10

    #1

    how to check out if a checkbox has been checked?

    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.


    [code=php]$request="selec t * from tablabu where (";
    if ($_POST['Picture'] == "on"){
    {$request=$requ est." `tablabu`.`Kind _of_document` LIKE 'PI') OR ("; }
    if ($_POST['Video'] == "on"){
    {$request=$requ est." `tablabu`.`Kind _of_document` LIKE 'VI') ;OR ("; }
    ETC...[/code]

    Thanks a lot for your help
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    Originally posted by Phaelle
    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="selec t * from tablabu where (";
    if ($_POST['Picture'] == "on"){
    {$request=$requ est." `tablabu`.`Kind _of_document` LIKE 'PI') OR ("; }
    if ($_POST['Video'] == "on"){
    {$request=$requ est." `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

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Raphaelle, please use [CODE] tags when you post source code.

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by Phaelle
        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.


        [code=php]$request="selec t * from tablabu where (";
        if ($_POST['Picture'] == "on"){
        {$request=$requ est." `tablabu`.`Kind _of_document` LIKE 'PI') OR ("; }
        if ($_POST['Video'] == "on"){
        {$request=$requ est." `tablabu`.`Kind _of_document` LIKE 'VI') ;OR ("; }
        ETC...[/code]

        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!

        Comment

        Working...