Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-21-2012, 03:52 AM   PM User | #1
chavad
New to the CF scene

 
Join Date: Oct 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
chavad is an unknown quantity at this point
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
chavad is offline   Reply With Quote
Old 11-21-2012, 02:17 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,387
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
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.
sunfighter is offline   Reply With Quote
Old 11-21-2012, 03:14 PM   PM User | #3
chavad
New to the CF scene

 
Join Date: Oct 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
chavad is an unknown quantity at this point
Dear sunfighter,

Thanks much; I finally figured it out.

Chava
chavad is offline   Reply With Quote
Reply

Bookmarks

Tags
database, form, mysql, php, query

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:15 PM.


Advertisement
Log in to turn off these ads.