Jump to content

Archived

This topic is now archived and is closed to further replies.

bassichonda96

template problem.

Recommended Posts

I have this...
[code]
function RandomNews(){
$query = mysql_query("SELECT * FROM tbl_news WHERE active='1' ORDER BY rand() LIMIT 0,1");
if (mysql_num_rows($query) == "1"){
$r = mysql_fetch_object($query);
$id = $r->id;
$title = $r->title;
echo "<a href='view_news.php?id=$id'>$title</a>";
}
}

$news = RandomNews();
$tags = array('title'=>'Sparetime Recreation','news'=>$news);

$tp->parseTemplate($tags);

echo $tp->display();[/code]

for some reason, when it parses the template, it puts the 'news' at the beginning of the parsed html. If i dont use the function RandomNews(); it works fine and puts it in the right place in the html... im confused.

Help please.

Thanks,
Adam

Share this post


Link to post
Share on other sites
I am not sure here, But i didnt no you can add a varable to a function() then call the varable to activate the function().

Have to read on that one sorry.

ok i got the function to work cheers but i read a little.

try one of these on the array
sort($tags)
rsort($tags)
asort($tags)

Share this post


Link to post
Share on other sites

×

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.