Jump to content

[SOLVED] Assign each value from mysql query automatically?


scooter41

Recommended Posts

Hi There... is there anyway after retrieving a mysql query, I can automatically assign "all values with a respective variable name"?

 

Example:

 

instead of saying

 

$name=$row['name'];

$email=$row['email];

$username=$row['username'];

 

that I can just say ...

 

retrieve data query...

then for all row fields, assign to a respective variable name?

 

I'm moving from a perl/cgi land which it was relatively simple there, so assume it is here too :)

 

Thanks for any help in advance.

No problem. Just fyi, the use of the double dollar sign means you are using a variable variable: the name of the variable you assign $v to is the value of the variable $k. Perhaps another example illustrates that better:

 

<?php
$foo = 'bar';
$bar = 'test';
echo $$foo; //is equivilant to echo $bar, since 'bar' is the value of $foo
//produces test
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.