简体   繁体   中英

How To make string / database into a variable

i hawe some problem here. i want make a string to be a variable,

$query = mysql_query("SELECT * FROM users Where username = 'fahmi'");
$result = mysql_fetch_array($query);

Result of the array is - $result['data']="$a"

$a = "This is a Result 1" ;
$b = "This is a Result 2" ;
$c = "This is a Result 3" ;

$final = $result['data'];
echo $final;

When i ran this code, result is $a but i want the result is "This is a result 1" , please help me, thanks...

If you want variable variables the you can achieve it this way:

$$a = "This is a Result 1" ;
$$b = "This is a Result 2" ;
$$c = "This is a Result 3" ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM