Ok, once again I've managed to over-think a piece of code. I've gotten this to the point where nothing I try completely works. The problem is a simple one. I need to generate variables from a MySql query result. No biggie. However, I want to iterate the variable names. For example, let's say I have a database of cars. I then have a field in the db called "Make". Ok, now, when I run a query I want to pull down the Makes of cars, and use them as $car1, $car2, $car3 etc. The while loop is no problem, and I figure that I can increment the number by one each time by setting a variable, ($x) to one before the while loop, and at the end of each loop increase $x by one. No problem. The issue is in the syntax of naming the variable. I can't, for example, use
$car$x = $row["Make"]
I've tried
$$car$x = $row["Make"]
but that's not right either. I want to be able to access this variable later by calling the value of $car1, or $car6, etc. Does anyone know the correct syntax for instantiating that variable?
$car$x = $row["Make"]
I've tried
$$car$x = $row["Make"]
but that's not right either. I want to be able to access this variable later by calling the value of $car1, or $car6, etc. Does anyone know the correct syntax for instantiating that variable?