How to retrieve data based on multiple checkbox selections

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesikatt04
    New Member
    • Apr 2010
    • 3

    #1

    How to retrieve data based on multiple checkbox selections

    I am creating a recommended education plan for our website. The thought was to have someone choose their top 3 functions , hit submit and based on the selection a list of courses are displayed. I have created the database. I have created the form. Please advise on the best way to make this happen.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    The user would hit a button or something to submit the form to your PHP code.
    In your PHP code you would detect what the user checked off, create your SQL Query based off of what they selected and then would update the database accordingly.


    -Frinny

    Comment

    • jesikatt04
      New Member
      • Apr 2010
      • 3

      #3
      Originally posted by Frinavale
      The user would hit a button or something to submit the form to your PHP code.
      In your PHP code you would detect what the user checked off, create your SQL Query based off of what they selected and then would update the database accordingly.


      -Frinny
      I do not want to do any data entry. I already have the data needed. I want the user to be able to choose from 3 options and the data associated with those options populate.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Oh do you mean you want to Display the (Text) descriptions for checkboxes based on something you've retrieved from the database??

        -Frinny

        Comment

        • jesikatt04
          New Member
          • Apr 2010
          • 3

          #5
          Originally posted by Frinavale
          Oh do you mean you want to Display the (Text) descriptions for checkboxes based on something you've retrieved from the database??

          -Frinny
          Yes exactly :)

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            You need to state what you need help with more clearly in the future.
            It would also Really help if you specified What programing language you're using to develop this application.

            I'm assuming that you are using PHP... just because the PHP/MySql package is so sweet.

            So here is a code snippet showing you how to connect to a database and retrieve data:

            Code:
            <?php
            $con = mysql_connect("localhost","peter","abc123");
            if (!$con)
              {
              die('Could not connect: ' . mysql_error());
              }
            
            mysql_select_db("my_db", $con);
            
            $result = mysql_query("SELECT * FROM Persons");
            
            while($row = mysql_fetch_array($result))
              {
              echo $row['FirstName'] . " " . $row['LastName'];
              echo "<br />";
              }
            
            mysql_close($con);
            ?>
            -Frinny

            Comment

            Working...