I've come across a problem that I don't know how to fix. I've tried changing stuff around but it still isn't working. Basically I am trying to read something from the database and output it to a string (it's a template system so I can't just print() it.
My code is:
The output is here: www.lfsdemoleague.cjb.net
I have checked the database and the record is correct, but it just shows one letter on the page
Any ideas?
My code is:
<?php
php
function template($data, $type) {
switch($type) {
case "tpl_news":
$sql = "SELECT * FROM `news`";
$sql = mysql_query($sql);
//$row = mysql_fetch_array($sql);
$num = mysql_num_rows($sql);
//return $num;
$return_data = "";
while($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
foreach($row as $row2=>$row3) {
$new_data = str_replace("{headline}", $row3["headline"], $new_data);
$new_data = str_replace("{content}", $row3["content"], $new_data);
$new_data = str_replace("{poster}", $row3["poster"], $new_data);
$new_data = str_replace("{date}", $row3["date"], $new_data);
$return_data = $new_data;
$new_data = $data;
//printf("Headline: %s; Content: %s; Poster; %s; Date: %s;", $row2["headline"], $row2["content"], $row2["poster"], $row2["date"]);
}
}
break;
}
//print "<br />";
//print $return_data;
return $return_data;
}
?>
I have checked the database and the record is correct, but it just shows one letter on the page
Any ideas?