setting variables in a while loop
Posted: Mon Feb 02, 2004 11:24 pm
Hey guys,
I have a bit of a problem.
I'd like to assign variables to equal the result of an sql query, returned in an array. for example, each time through the loop a new variable is created $variable(number 1 - 12) = the element in the returned array from the sql query.
Here's my code.
$sql = "SELECT button_text FROM ".$table." ORDER BY buttonID";
$users = mysql_query($sql);
$i = 0;
while ($user = mysql_fetch_array($users)) {
$variable(number 1 - 12) = $user["button_text"]; <--- I want to set new var here.
$i++;
}
Any thoughts or help would be appreciated.
TIA.
I have a bit of a problem.
I'd like to assign variables to equal the result of an sql query, returned in an array. for example, each time through the loop a new variable is created $variable(number 1 - 12) = the element in the returned array from the sql query.
Here's my code.
$sql = "SELECT button_text FROM ".$table." ORDER BY buttonID";
$users = mysql_query($sql);
$i = 0;
while ($user = mysql_fetch_array($users)) {
$variable(number 1 - 12) = $user["button_text"]; <--- I want to set new var here.
$i++;
}
Any thoughts or help would be appreciated.
TIA.