Re: explode? (table field to a variable of same name)
| From: | Rasmus Lerdorf | Date: | Tue, 19 Feb 2002 22:40:33 +0000 |
| Subject: | Re: explode? (table field to a variable of same name) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85449@lists.php.net to get a copy of this message | ||
This creates all the variables you asked for and also prints each one in a
column of a table.
foreach($row as $key=>$val) {
$$key = $val;
echo "<td>$val</td>";
}
-Rasmus
On Tue, 19 Feb 2002, Baloo :0) wrote:
> How can I assign automatically all fields of a database to a variable of
> the same name?
>
> Instead of having to manually do
> $user_id=$row["user_id"];
> etc
>
> Then how could I know the number of fields in the table so I can do a
> loop to print them all in html?
>
> In advance, thanks for your help.
>
> Alfredo
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>