开发者

How to convert variables from MYSQL result into PHP variables with same name?

I am running this mysql query:

$result = mysql_query("SELECT * FROM  userdetails WHERE  userid= '$userid'");
$row = mysql_fetch_array($result);

The result is a row of 100 variables with different names such as $row['name'], and $row['email'], etc...

How can I convert all of these to just $name and $email, etc... in php?

It would save so much time to write this prog开发者_运维知识库ram....


Short anwser: extract

long anwser : don't. It may seem like a good anwser now but if you use it much it will become a problem keeping track of stuff.


http://au2.php.net/extract


You probably don't ultimately want to do that, but the extract() function does this.

http://us3.php.net/manual/en/function.extract.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜