TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 10-23-2007, 08:56 PM   #1 (permalink)
The Contributor
 
Join Date: Sep 2007
Posts: 89
Thanks: 1
Sam Granger is on a distinguished road
Default 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.
Sam Granger is offline  
Reply With Quote
Old 10-24-2007, 12:17 AM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 700
Thanks: 2
Salathe is on a distinguished road
Default

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

__________________
Salathe is offline  
Reply With Quote
Old 10-24-2007, 11:51 AM   #3 (permalink)
The Contributor
 
Join Date: Sep 2007
Posts: 89
Thanks: 1
Sam Granger is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
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
Sam Granger is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:38 PM.

 
     

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