Re: a function for retuned vatiable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ross wrote:
> What I need is a quick way to assign variable names to the same value of the 
> row name.
> 
> example..
> 
> $query= "SELECT * from $table_name WHERE sname=='hulford'";
> 
>   $result = mysql_query($query) or die('Error, query failed');
>  while ($row=mysql_fetch_array($result)) {
> 
> 
> $email = $row['email'];
> $name=$row['name'];
> $address = $row['address'];
> 
> //this goes on for 30 fields is there a way to automate this?

extract($row);

// OR

foreach ($row as $k =. $v) $$k = $v;

// OR just use $row['email'] etc. i.e. why make another copy of
each piece of data?

> 
> 
> } 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux