Re: problem referencing a mysql object
| From: | BAO RuiXian | Date: | Wed, 04 Feb 2004 17:30:58 +0000 |
| Subject: | Re: problem referencing a mysql object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176821@lists.php.net to get a copy of this message | ||
craig wrote:
Hi, the problem is that I am trying to use a varible in the objects attribute name. the offending line of code is: echo "<img src='$row->cPic$count' border='1'>"; this is giving the warning: Undefined property: cPic I have tried playing with eval and variable variables to get 'cPic$count' to look like 'cPic1' before trying to How about $row->{cPic.$count}?Best Bao
use it, but nothing is working. There has to be a way
to do this. Any help is greatly appreciated.
-Craig
while ($row = mysql_fetch_object($result)) {
//other code...
$count = 1;
while ($count <= $row->tiPicCount) { echo "<img src='$row->cPic$count' border='1'>";
++$count;
}
//other code...
}