views:

60

answers:

4

My approach:

<?

switch($id) 
{ 
    case 1:
?>
        a lots of html stuff goes here...
<?    
    break;  
    case 2:
?>
        a lots of html stuff goes here2...
<?    
    break;        
}

?>

Is there any way to do this thing prettier? I mean more readable or something? I would really appreaciate that. (haven't learned smarty yet...)

+9  A: 

Break out the HTML into separate files and include them in the relevant blocks.

Ignacio Vazquez-Abrams
Yeah, probably that's the best solution here.
hey
A: 

if statements might be cleaner here:

<? 
if ($id == 1) {  
?> 
        a lots of html stuff goes here... 
<?     
}
if ($id == 2) {
?> 
        a lots of html stuff goes here2... 
<?     
} 
?> 
RedFilter
+1  A: 

include as has been mentioned. Or if you really want to separate it out you could use a template engine such as Smarty

Cfreak
Smarty won't help in this very case. And such a separation should be done in *mind*, not code. Smarty has {PHP} tag as well....
Col. Shrapnel
A: 

I'd recommend a full templating solution like Smarty (which Cfreak has mentioned already), it is a good idea to separate presentation from logic.

barfoon
PHP is already perfect template system.
Col. Shrapnel
I realize that, however I find the code ugly, and it allows for more of a separation between presentation and logic.
barfoon