blackwater dev wrote:
I have a chunk of html data that I want to output for each iteration through
a db result

while($result){

   $list.=file_get_contents("my_template_file.php");

}
return $list;

The template file looks like this:

<table>
    <tr>
         <td><?php echo $result["name"];?></td>
    </tr>
</table>

I basically want a good way to keep the template file out of the class so I
don't have to code:
 $list.="<table><tr>...etc

The problem is with the method I have, it doesn't translate the
vars...what's the best way to do this?

Thanks!


I wouldn't use a class/function to output anything. Why not just return the data, and loop thru that?

function myFunction() {
/* ----- Code ----- */
while ( $data = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
        $return_data[] = $data;
}
}
return $return_data;



$myData = myFunction();
foreach ( $myData as $data ) {
        echo <<<END
<table>
        <tr>
                <td>$data["name"]</td>
        </tr>
</table>
END;
}

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to