Re: Anyone Up?
| From: | jtjohnston | Date: | Fri, 01 Feb 2002 07:34:13 +0000 |
| Subject: | Re: Anyone Up? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83072@lists.php.net to get a copy of this message | ||
Luke is that 6:47 pm tomorrow? :) You lost an entire day!
Enough Oz Jokes. Here is my predicament in Canada :-)
$varname = "Check".$i;
$varname = "Check1" but I want $varname = "Your Name1" to "Your
Name12".
One more try? :)
<INPUT TYPE="checkbox" NAME="Check1" VALUE="Your Name1">
<INPUT TYPE="checkbox" NAME="Check2" VALUE="Your Name2">
<INPUT TYPE="checkbox" NAME="Check3" VALUE="Your Name3">
etc.
for ($i = 1; $i <= $NMax; $i++)
{
#$varname = "$Check".$i;
$varname = "Check".$i
#echo $varname;
if ($varname)
echo "$varname = $i<br>";
}
Thanks much!
John (Brr it's cold up here.)
Luke Welling wrote:
> "Jtjohnston" wrote:
> > Anyone Awake? Up?
> It is 6:17 pm. I would have trouble sleeping at this time of day :)
>
> > I'm using 12 checkboxes
> >
> > <INPUT TYPE="checkbox" NAME="Check1" VALUE="Your
> > Name">
> >
> > dynamically generated by mysql. Each has an id as primary index so I do
> > this:
> >
> > <INPUT TYPE=\"checkbox\" NAME=\"Check".$mydata->id."\"
> > VALUE=\"".$mydata->yourname."\">
> >
> > When I submit, I want to echo to see if anyone clicked on them. But I
> > can't get my variable right to find $check1 through $check12. How do I
> > express in a for loop. $Check.$i does not work of course!
>
> There are two ways I can think of.
>
> 1) You could change the way that your code creates the checkbox names, so
> that rather than getting 12 variables, you get an array with 12 elements.
>
> 2) You could repeat your MySQL query on the echo page, and loop though code
> something like this:
> $varname = "Check".$mydata->id;
> echo $$varname;
>
> Good Luck.
>
> Luke Welling.
> --
> PHP and MySQL Web Development
> by Luke Welling and Laura Thomson
> http://www.amazon.com/exec/obidos/ASIN/0672317842