Jump to content


Photo

template problem.


  • Please log in to reply
2 replies to this topic

#1 bassichonda96

bassichonda96
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationVincennes, IN

Posted 23 September 2006 - 06:48 AM

I have this...
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();

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
Adam M.
Vincennes, IN - College Student
bassichonda96@gmail.com

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 September 2006 - 06:54 AM

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)
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 bassichonda96

bassichonda96
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationVincennes, IN

Posted 23 September 2006 - 07:11 AM

I figured it out, i needed to return instead of echo in the function.. works fine now thanks for the help.
Adam M.
Vincennes, IN - College Student
bassichonda96@gmail.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users