bassichonda96 Posted September 23, 2006 Share Posted September 23, 2006 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 Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 23, 2006 Share Posted September 23, 2006 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 arraysort($tags)rsort($tags)asort($tags) Quote Link to comment Share on other sites More sharing options...
bassichonda96 Posted September 23, 2006 Author Share Posted September 23, 2006 I figured it out, i needed to return instead of echo in the function.. works fine now thanks for the help. 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.