Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How could I initialize a templating system?

    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.
    PHP Code:
        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>";
        } 
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •