Re: a function for retuned vatiable
| From: | David Tulloh | Date: | Mon, 02 Oct 2006 12:17:55 +0000 |
| Subject: | Re: a function for retuned vatiable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242467@lists.php.net to get a copy of this message | ||
extract() - http://www.php.net/extract - does what you are
after.
However often it's easier to handle the array as you have a better idea
of what variables are available, particularily if you are working with
multiple tables.
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?
>
>
> }
>