Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pass Value of Radio Buttons through SQL Query

    Dear Everyone,

    I am very new to both PHP and MySQL. I have a MySQL database that includes a field called "max_rooms" with the values 1 or 2 set for each row in the database it applies to. In my HTML document, I have a form containing a question named "max_rooms" with two choices that are radio buttons. My PHP and MySQL are connected properly; I just don't know what to write in the form results PHP document so that the values are passed correctly. I think it might be something like the following, but I'm not sure and anyway don't know what to do after that:

    $sqlquery = "SELECT * FROM hallonly";
    $sqlquery .=" where max_rooms = $_POST['max_rooms']";

    Thanks!!
    Chava

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 593 Times in 592 Posts
    Your form with radio buttons:
    Code:
    <form name="myForm" action="test.php" method="post">
    <h4>Enter Max Number of Rooms.</h4>
    <input type="radio" name="rooms" value="1" /> : 1 Room<br />
    <input type="radio" name="rooms" value="2" /> : 2 Rooms<br />
    <input type="submit" value="Submit">
    </form>
    Calls this php file "test.php":
    PHP Code:
    <?php
    echo $_POST["rooms"];
    ?>
    So if your form is correct [the one I showed you] your php is correct.

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear sunfighter,

    Thanks much; I finally figured it out.

    Chava


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •