Posted by Andy Hassall on 04/03/07 22:54
On Tue, 3 Apr 2007 15:40:20 +0200, "Rolf Mander" <rolf.mander@spam.com> wrote:
>Hi,
>I need to use dynamic variable names but for objects.
>As you know something like that works fine:
>
>$variable="content";
>$part="able";
>echo ${"vari".$part};
>// gives out content
>
>but i need to use a database object after a mysql query something like that
>
>$sqlresult= mysql_query("SELECT * FROM t_table_xy");
>while (($obj = @mysql_fetch_object($sqlresult)) {
>echo ${"obj->f_".$fieldname[1]};
You'll need a temporary variable for the name.
$field = 'f_' . $fieldname[1];
echo $obj->$field;
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|