Re: Variable Variables in PHP
| From: | Jason Stechschulte | Date: | Wed, 27 Jun 2001 13:55:53 +0000 |
| Subject: | Re: Variable Variables in PHP | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9864@lists.php.net to get a copy of this message | ||
On Wed, Jun 27, 2001 at 12:03:42PM +1000, Morgan Tocker wrote:
> ## THIS SHOULD SUBMIT SOMETHING LIKE THIS >>>>
>
> test.php?name1=avalue&email1=avalueagain&name2=secondname&email2=secondemail
>
> THE PROBLEM:
> From PHP with variable variables, how do I change $name1 and $email1 into -
>
> ## for all $name.$x values do this......
> $sql = "UPDATE name_and_email SET name = '$name1', email = '$email1'
> WHERE
> id = '$id'";
Put it inside of a loop.
for($i = 1; $i < 3; $i++) {
echo ${"name$i"};
}
This will print out both names. Hopefully you can figure out how to
modify this to create the sql code you want.
--
Jason Stechschulte
jpstech@unoh.edu
--
It's the Magic that counts.
-- Larry Wall on Perl's apparent ugliness