TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Help! Trying to template something here. :) (http://www.talkphp.com/absolute-beginners/1329-help-trying-template-something-here.html)

Sam Granger 10-23-2007 07:56 PM

Help! Trying to template something here. :)
 
Hey guys. I'm aving trouble templating a while statement. See the code below.

PHP Code:

<?php

/**
 * @author Sam Granger
 * @copyright 2007
 */

defined('parent') or die('Direct access to this file is not allowed!');

$interface = new Interface('array');
$interface->title "News";
$interface->keywords "News";

$database = new MySQL();

$connection $database->Connect($DB_SERVER$DB_USER$DB_PWD$DB_NAME);

$sql "SELECT id, title, DATE_FORMAT(published,'%d-%m-%Y') AS published FROM news";
$query $database->Query($sql);

while(
$array $database->FetchArray($query)){
    
extract($array);
    echo 
"<p>$id$title$published</p>";
}

$interface->content "while content should really go here!";
$interface->Display();

?>

Ok, I want $interface->content to equal all the rows outputted by the while statement.

How can I do this? Looking forward to suggestions. Template system basically replaces a tag in a file with the content that I want.

Salathe 10-23-2007 11:17 PM

PHP Code:

$interface->content '';
while(
$row $database->FetchArray($query)) {
    
$interface->content .= sprintf('<p>%s, %s, %s</p>'$row['id'], $row['title'], $row['published']);



Sam Granger 10-24-2007 10:51 AM

Quote:

Originally Posted by Salathe (Post 3229)
PHP Code:

$interface->content '';
while(
$row $database->FetchArray($query)) {
    
$interface->content .= sprintf('<p>%s, %s, %s</p>'$row['id'], $row['title'], $row['published']);



Thanks! That did the trick, awesome Salathe! :D


All times are GMT. The time now is 06:06 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0