Infected-Waffle Posted August 13, 2006 Share Posted August 13, 2006 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]<?phpsession_start();if (isset($_SESSION['logged_in']) { $nav = '» 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] Quote Link to comment Share on other sites More sharing options...
trq Posted August 13, 2006 Share Posted August 13, 2006 You'll need to be alot more specific. Were not mind readers. Quote Link to comment Share on other sites More sharing options...
Infected-Waffle Posted August 13, 2006 Author Share Posted August 13, 2006 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. ^^; Quote Link to comment Share on other sites More sharing options...
trq Posted August 14, 2006 Share Posted August 14, 2006 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. Quote Link to comment Share on other sites More sharing options...
Infected-Waffle Posted August 14, 2006 Author Share Posted August 14, 2006 Thanks I'll try those. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.