开发者

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

开发者 https://www.devze.com 2022-12-10 00:48 出处:网络
I am running this mysql query: $result = mysql_query(\"SELECT * FROMuserdetails WHEREuserid= \'$userid\'\");

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

精彩评论

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