Page 1 of 1

dynamic variable names ?

Posted: Wed Jun 12, 2002 3:15 am
by etienne
Knowing i obtain the values of a ENUM column (content of $liste_enum in the following lines), is it possible to write the following lines

$query="SELECT titre_fr from ".$item." WHERE web_fr IS NOT NULL AND type='".$liste_enum[0]."' ORDER BY titre_fr";
$result0=mysql_query($query,$bdlink);

$query="SELECT titre_fr from ".$item." WHERE web_fr IS NOT NULL AND type='".$liste_enum[1]."' ORDER BY titre_fr";
$result1=mysql_query($query,$bdlink);
$nb1=mysql_num_rows($result1);

...

in a loop using dynamic variable names (i use them in a html file) ?

regards,
Etienne

Posted: Wed Jun 12, 2002 6:00 am
by jason
What is the end result you are trying to accomplish, as I really don't understand what you are trying to do to get there.

Posted: Wed Jun 12, 2002 7:03 am
by etienne
I retrieve several set of lines from a table based on the different values of a ENUM colomn.

Instead of write several times the same lines (see the two queries in my first message) in which only the test value to select the lines change ($list_enum[0] in the first query and $list_enum[1] in teh second one), i would like to know if it is possible to define a variable which name (not the value) could dynamically defined.

So, the query and could be stored in a variable which name is different each step of the loop. Is it clearer ??

Anyway, i solved my problem : i store the query result in an array and i write my html page from this array.


Thanks to answer me
Etienne