I need to generate a variable with an arbitrary name. I have the following code, which does not work:
$vv = mysql_query("SELECT * FROM $tabela ORDER BY rand() LIMIT 3");
$i=1;
while($v = mysql_fetch_array($vv)){
$vertical.$i=$v['arquivo'];
$i++;
}
echo'
<img src="img/fotos/'.$vertical1.'"> <br>
<img src="img/fotos/'.$vertical2.'"> <br>
<img src="img/fotos/'.$vertical3.'">
';
I would like the query to return 3 variables: $vertical1
, $vertical2
and $vertical3
Note: In the database the 'file' field has the 'format' included. Ex .: foto.jpg
Obs2: I believe the problem is in concatenation $vertical.$i
...