CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   Pass Value of Radio Buttons through SQL Query (http://www.codingforums.com/showthread.php?t=282661)

chavad 11-21-2012 03:52 AM

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

sunfighter 11-21-2012 02:17 PM

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.

chavad 11-21-2012 03:14 PM

Dear sunfighter,

Thanks much; I finally figured it out.

Chava


All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.