Variables in PHP/MySQL
Let's say I have something like this:
PHP Code:
PHP Code:
I've tried doing it like: PHP Code:
|
What's wrong with the 2nd of the three code blocks?
if the coding is weird, it calls for a recoding ;) you are effectively defining $bar as a variable containing a string, and then assigning that string to $foo therefore you'll end up with $foo == "\$row['Price']*\$row['Quantity']" every time. might be doable with sprintf havn't tried that yet though in a circumstance like this O_o overall it looks rather weird, as you say, and not neat. Best way would be to do it like in the 2nd code block (where btw $foo gets overwritten every time if there's more than one data row, unless it's intended) |
Quote:
|
yw :)
|
All times are GMT -5. The time now is 02:10 PM. |