dynamic variable names ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
etienne
Forum Newbie
Posts: 2
Joined: Wed Jun 12, 2002 3:15 am

dynamic variable names ?

Post 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
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
etienne
Forum Newbie
Posts: 2
Joined: Wed Jun 12, 2002 3:15 am

Post 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
Post Reply