Variable inside queryName

$myQuery=mysql_query("select name from myTable1
order by id") ; 

while($row = mysql_fetch_array($myQuery) )
{
echo $row['name'];
}

The code above works fine.

However, I like to use a variable inside queryName “$myQuery”
So I made the trial code for it like the following.


$myVariable=1;

[COLOR="Red"]${myQuery$myVariable}[/COLOR]=mysql_query("select name from myTable1
order by id") ; 

while($row = mysql_fetch_array([COLOR="red"]${myQuery$myVariable}[/COLOR]) )
{
echo $row['name'];
}

But the trial code above causes “syntax error, unexpected T_VARIABLE”.

How can I put a variable inside queryName?

Variable variables.


$queryname = "myQuery".$yourvar;
$$queryname = mysql_query .....

Thank you. it works fine.