Jump to content

template problem.


bassichonda96

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
Link to comment
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)
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.