In a database I’m working with, there are 6 columns with names:
price1dollar
price2dollar
price3dollar
price4dollar
price5dollar
price6dollar
I thought that once I had the result set for the query, I could access it like so with PHP:
for($i = 1; $i <= 6; $i++) {
echo $row['price'+$i+'dollar'].'<br />';
}
and that would print out all the values, but I’m not getting anything printed.
if I use:
echo $row['price1dollar'];
then the value is printed out fine.
I have echoed the value of $i and it prints out 1 to 6 fine, so I don’t know whats going on.
Is the $row['price'+$i+'dollar'] syntax not allowed?
Many thanks
should be
in PHP there are
.(dot) string connections (+(plus) is i think for example in Java)