Yes, just follow the second part of my directions, then. If your
variable is named X1, then in your radio button, in the Inspector, in
the Value field, enter
<?php echo $X1; ?>
all of that, just like that, and you should get the value into the
form element when PHP extracts the value and prints it out as the page
loads. If you view the source in your browser (from the server), you
will see something like this (assuming that $X1 was equal to ‘4 Euros’:
<input type="radio" name="price" value="4 Euros" />
So that gets it into your form, as shown to the browser, and completed
by the user. Next, you have to take this into your form handler (the
page or script that lives at whatever URL you entered into the Action
field in the Form Setup dialog on your page) and get the variables out
again.
Radio buttons are slightly weird compared with other form elements. In
a radio button group, all of the fields are named exactly the same,
and they only vary by their value. So you might have this:
<input type="radio" name="vegetable" value="broccoli" />
<input type="radio" name="vegetable" value="spinach" />
<input type="radio" name="vegetable" value="carrots" />
This ensures that the user can only choose one of the set. When you
get the form contents back at your handler, only one of the three (or
none, if you don’t set a default) will actually be sent to you:
print $_POST['vegetable']; // => 'carrots'
You handle checkboxes in a different manner, because they allow
multiple selection:
<input type="checkbox" name="vegetable[]" value="broccoli" />
<input type="checkbox" name="vegetable[]" value="spinach" />
<input type="checkbox" name="vegetable[]" value="carrots" />
Notice the square brackets at the end of the name attribute – that
tells the browser to send back an array of values for that one
variable name. If you named them all the same thing, and without the
brackets, then you would only get the “last” selected value, no matter
how many were actually selected.
Back at the handler, assuming that two of the three were chosen, you
might see:
print_r($_POST['vegetable']); //=> Array { 0 => 'broccoli', 1 =>
‘spinach’ }
So you have to handle them differently when reading back the value.
Checkboxes that are not checked are never sent by the browser – so
you can’t look at a form submission and actually know how many
unchecked fields there were, only the checked ones.
Walter
On Jun 22, 2011, at 7:09 PM, Shane wrote:
Walter,
Ok. I see what you are saying 90% here. Here is how I was using
the PHP and DB connect:
- “PHP include PHP action” to make the PHP header information that
is required.
1.a. I am setting the file name to test.php
- “MYSQL Connect action”. to make the DB connection. (I use a
read only login to connect)
- “MySQL Get Records action” to pull the information into the page
and set the variables.
- I am also using some of the other PHP actions to setup some of
the server side stuff if it comes up in the future. easier to do it
now then later.
Now I am at the point where I was going to set values inside of the
radio button at the radio button. I have the inspector open and
looking at the “Value” box for the radio button. I should be able
to have the value set to a variable of my choice brought in through
the DB read.
Do i just set it to a variable name? or is there a syntax like
[[x1]] that I have to do?
I am having an Apache test server setup tomorrow using the
VirtualHostX software on a desktop I have laying around.
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options