Jump to content

Listing results in a template system


Infected-Waffle

Recommended Posts

Okay so I have this templating system and I want to retrieve all my new results but they allhave togo into one variable. I've brainstormed for a while but I can't think of anything. Here's the code:

[code]<?php

session_start();

if (isset($_SESSION['logged_in']) {
$nav = '&raquo; User CP';
} else {
$nav = '<form action="index.php?page=submit&mode=login" method="post" name="login">
Username:<br>
<input name="username" type="text" size="17" maxlength="15"><br>
Password:<br>
<input name="password" type="password" size="17" maxlength="16"><br>
<input name="Login"  value="Login" type="button">
</form>';
}

include("dbconnect.php");
include("templates/templatesys.php");

switch($_GET['page']) {
case 'templates' :
break;
default:
$query = 'SELECT * FROM news ORDER BY id DESC';
$result = mysql_query($query);

if ($result) {
while( $row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
}
}
$data = array('CONTENT' =>);

$tpl = new template;
$tpl->parseTemplate('templates/main.tpl', $data);
$tpl->display();

    break;
}

?>[/code]
Link to comment
Share on other sites

Sorry.

Alright basically when I didn't use this templating system I would put an echo in the while. But now I started using this template system and What I need to basically do is put all the entries the query returns into one variable which will then be placed in the $data array and parsed.

Hope that's  specific enough. ^^;
Link to comment
Share on other sites

How do you want to join each record? You could simply concatinate them...

[code=php:0]
if ($result) {
  while( $row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
    $content .= $row['content'];
  }
}
[/code]

But I cant see that being much use to you. You could also put them into an array...


[code=php:0]
if ($result) {
  while( $row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
    $content[] = $row['content'];
  }
}
[/code]

Hard to see what it is you need really.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.