...

View Full Version : How could I initialize a templating system?



SDP2006
05-18-2004, 10:19 PM
How, with this code, could I initialize a templating system? Someone, a very advanced php coder told me I shouldn't, or at least he doesn't, mix HTML inside of a function. It doesn't look very clean to me, so, how could I do it? I have a system to replace {nav} and {footer}, etc. but how can I do it inside of a function like this? Thanks to all.
function select($mode)
{

$this->mode = $mode;
$this->connect();

$result = "SELECT id,author,topic,mood,date,entry,np,month FROM blog ORDER BY id DESC";
$query = mysql_query($result) or die(mysql_error());

echo "<div style='text-align: left;'>";

if($query){

if(mysql_num_rows($query) == "0"){ echo "No information in database!"; }

else{
while($row = mysql_fetch_assoc($query)){
$this->id = $row['id'];

echo '<h1>'.$row['topic'].'</h1><span class="info"><center>'.$row['date'].' | '.$row['mood'].' | '.$this->commentsNumber($this->id).'</center></span>';
echo '<span id="double">' . stripslashes($row['entry']) . '</span><br /><p align="right">';

switch($this->mode){

case "reg":
echo "";
break;

case "edit":
echo ' | <a href="?cpmode=editpost&id="'.$this->id.'"><b>Edit Post</b></a>';
break;

case "del":
echo ' | <b><a href="deletepost.php?bid='.$this->id.'">Delete Post</a></b>';
break;

default:
NULL;
}

echo "</p>";
}
}
}
echo "</div>";
}

SDP2006
05-19-2004, 02:03 PM
:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum