oi ... typo! see below. sorry :(
~Chris
On Tue, 19 Feb 2002, Christopher William Wesley wrote:
> This may not be what you want to do, but should give you some hints.
> (This is my code which I use to simply dump any SQL table into an HTML
> table I can view in a browser ... for small
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 "$val";
}
-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 n
This may not be what you want to do, but should give you some hints.
(This is my code which I use to simply dump any SQL table into an HTML
table I can view in a browser ... for small tables, of course.)
Using MySQL as an example:
// assuming you ran a query and stored results in $mysql_result_s
First grab an associative array of the variables from the database with
mysql_fetch_array()
Then use extract($array); to extract all of the variables in the array
to the symbol table:
www.php.net/extract
Simon
Baloo :0) wrote:
>How can I assign automatically all fields of a database to a va
: Baloo :0) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 3:41 PM
To: [EMAIL PROTECTED]
Subject: [PHP] explode? (table field to a variable of same name)
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=$ro
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
6 matches
Mail list logo