[nycphp-talk] need some form help...
Melissa
melissa at inexact.info
Sun May 25 11:17:23 EDT 2003
If you have a table of the options for your radio buttons, for example:
id option_value
1 red
2 blue
3 yellow
Build a recordset selecting all the options (SELECT * FROM options), and
loop through the results, having php spit out the appropriate tags where
necessary:
<?php do {
echo "<label><input type=\\"radio\\" name=\\"selections\\" ";
echo "value=\\" " . $row_RSOptions['id'] . "\\">" .
$row_RSOptions['option_value'] . "</label><br>";
} while ($row_RSOptions = mysql_fetch_assoc($RSOptions)); ?>
Same thing for checkboxes - just replace the input type radio with the input
type checkbox.
> -----Original Message-----
> From: jfreeman at amnh.org [mailto:jfreeman at amnh.org]
> Sent: Sunday, May 25, 2003 9:28 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] need some form help...
>
>
> Good morning everyone. Thanks so much for all of your help so far. I am
> learning a lot... but.. I'm stuck again.
>
> As you prolly know, I'm building a LAMP app. for some scientists
> who are doing
> a survey of 1000 wasps nests.
>
> I have the form completed. For all the parts of the form that
> involve drop-
> down lists, I have working code that goes into a table and grabs
> the rows in
> the table to build the drop down list in the form.
>
> Checkboxes and radio buttons are hard coded into the form ... I'd
> like to be
> able to have those be built dynamically as well, using rows from various
> tables in the database but I can't figure that one out yet...
>
> Here's a code snippet of what I use to build the drop downs:
>
> ---------------snip--------------
> <?php
> $query = mysql_query("select * FROM author");
>
>
> echo "select name=\\"Array[author]\\">
> <option value=\\"\\">--select author--</option>\
;
> while ($row = mysql_fetch_row($query)) {
> print "<option value=\\$row[0]\\">$row[1]</option>\
";
> }
> print ("</select>");
>
> --------------snip----------------
>
> so.. this works in terms of building the drop down list. I have no idea
> whether it will work with an insert statement so that, once I've
> built the
> entire POST array from the form, whatever value the surveyor
> chooses from the
> drop down list will be inserted in the right place in the database.
>
>
> I'm COMPLETELY lost with regards to how to use the name=Array[blah-blah]
> construct when it comes to checkboxes and radio buttons...
>
> what do I do with the 'value="somevalue"' part of the checkbox or radio
> button? where does that go with regards to the Array[blah-blah] part?
>
> Another point of confusion... one of the fields in the survey form
> is 'survey_date'.
>
> I have field of type 'date' in my 'specimen' table... I'd like to have
> the 'survey_date' be handled automagically for the surveyor by
> PHP and MySQL..
> any suggestions on how best to accomplish that?
>
> There's more help that I need but this is a relatively digestible chunk..
>
> Thanks folks!
>
> J.
>
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
More information about the talk
mailing list