Re: Smart ass form
| From: | Chris Earle | Date: | Sun, 21 Jul 2002 23:46:05 +0000 |
| Subject: | Re: Smart ass form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108772@lists.php.net to get a copy of this message | ||
+--------+--------+------------------+-------------------------+
| expid | devid | devlanguage | devtime |
+--------+--------+------------------+-------------------------+
| 1 | 1 | PHP | less than 1 year |
| 2 | 1 | MySQL | less than 1 year |
| 3 | 1 | HTML | more than 5 years |
+--------+------+--------------------+-------------------------+
I'll use that as the template:
I'll assume that you know how to get the expid and devid in there and I'll
just put them in there as numbers.
<? $devselect = "<SELECT NAME=\"devtime[]\" SIZE=\"1\">
<OPTION VALUE=\"<1y\">Less than 1 year
<OPTION VALUE=\">5y\">More than 5 years
etc
</SELECT>";?>
<FORM><TABLE>
<TR>
<TH>expid</TH><TH>devid</TH><TH>devlangu</TH><TH>devtime</TH>
</TR>
<!-- a loop will generate each new row -->
<TR>
<TD>1</TD><TD>1</TD><TD><?=$LanguageName[$expid]?><INPUT
TYPE="Check"<?
if ($UserKnows[$expid]) { echo " CHECKED"; }?>
VALUE="language[]"></TD><TD><?=$devselect?></TD>
</TR>
<!-- this will end what the loop outputs -->
<TR>
<TD>2</TD><TD>1</TD><TD><?=$LanguageName[$expid]?><INPUT
TYPE="Check"<?
if ($UserKnows[$expid]) { echo " CHECKED"; }?>
VALUE="language[]"></TD><TD><?=$devselect?></TD>
</TR>
etc...
<!-- here's the hardcoded extras -->
<TD>-</TD><TD>1</TD><TD><INPUT TYPE="Text"
NAME="DevSetLang[]"
VALUE=""><TD><?=$devselect?></TD>
etc..
</TABLE></FORM>
Now you can access them by (I think) doing something like this:
if (!empty($_POST["language"][0])) // (I think that check boxes give "" if
they're not checked)
if (!empty($_POST["DevSetLang"][0])) // you might consider making a separate
"devselect" variable for the text boxes, which will make it easier to check
(the array index will work easier)
I hope that that helps.