[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] Dynamic Variable Creation from Forms
From:       Nuno Silva <nuno.silva () websolut ! net>
Date:       2001-01-31 23:53:33
[Download RAW message or body]

[ rswfire ] wrote:

> I have a problem I'm not sure how to fix.
> 
> PART I
> 
> I have a form on a page that creates its variables dynamically.  
> Here's an example:
> 
> mysql_db_query($db, "SELECT * FROM table");
> while ($row = mysql_fetch_array($result))
> {
> 
>  echo "<INPUT TYPE='CHECKBOX' NAME='chk_".$row["checkboxtype"]."'>";
> 
> }
> 
> PART II
> 
> I need to make reference to these dynamically created variables.  How 
> do I do this?  This does not work, obviously:
> 
> $chk_.$row["checkboxtype"]
> 
> Thanks in advance...
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> 
> 
$temp = "chk_$row";
echo $$temp["checkboxtype"];

the trick is $$var_name ;)

have fun,
Nuno




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic