Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Conditionally including HTML code in PHP?
New Posts  All Forums:Forum Nav:

Conditionally including HTML code in PHP?

post #1 of 11
Thread Starter 
Hey,

I can't find much on this, and everything I have tried has failed.

Basically, I need to have the page decide what HTML element to display given the PHP condition.

I intended to simply create an if statement. However, "include ('include/example.html')" does not work, it just doesn't do it. I'm assuming that's due to the mix of languages.

The HTML elements include a very large amount of code, so I can't have it all on that page.

Any ideas?
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
post #2 of 11
You can always echo the HTML code into the document tongue.gif

Maybe if include or require doesn't work the way to go would be to make a mini version of you html code getting rid of all the unnecessary characters in the code and paste it raw inside an echo.

I haven't done any research, these are just my ideas. I always do some research before implementing this kind of thing to make sure I choose the easiest way first.
    
CPUMotherboardGraphicsRAM
i5 750 @ 3.6 P7P55 EVO ASUS 5870 V2 @950/1250 8gb @1600 cas 9 @1.5v 
Hard DriveOptical DriveCoolingOS
crucial m4 256gb + 3tb seagate none venomous-X + 2 P/P yate loons @5v 8 pro x64 + mint 14 cinnamon x32 
MonitorKeyboardPowerCase
PX2370 random Antec HPC-850 BX-500 aerocool 
MouseMouse PadAudio
CM Storm Spawn QcK+ Shure SRH 750DJ+FiiO E5 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
i5 750 @ 3.6 P7P55 EVO ASUS 5870 V2 @950/1250 8gb @1600 cas 9 @1.5v 
Hard DriveOptical DriveCoolingOS
crucial m4 256gb + 3tb seagate none venomous-X + 2 P/P yate loons @5v 8 pro x64 + mint 14 cinnamon x32 
MonitorKeyboardPowerCase
PX2370 random Antec HPC-850 BX-500 aerocool 
MouseMouse PadAudio
CM Storm Spawn QcK+ Shure SRH 750DJ+FiiO E5 
  hide details  
Reply
post #3 of 11
Funny that... this is what PHP was basically first used for tongue.gif
Code:
<?php
if ( $some_condition ):
?>
<b>This is some HTML code</b>
<?php 
else:
?>
<b>This is different HTML code</b>
<?php endif; ?>

This uses the PHP alternate syntax to make things a little cleaner: http://php.net/manual/en/control-structures.alternative-syntax.php

For your include example, you don't really need that, just do this:
Code:
if ( $some_condition )
      include ( "/include/some_html.php" );
else
      include ( "/include/some_html_2.php" );

You can include .html files so I don't know why it isn't working, but doesn't matter - just rename your HTML files to PHP files and include those. PHP files don't HAVE to include PHP code.
Another option is the Smarty template engine (much better).
Edited by tompsonn - 10/22/12 at 5:05pm
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
post #4 of 11
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

Funny that... this is what PHP was basically first used for tongue.gif
Code:
<?php
if ( $some_condition ):
?>
<b>This is some HTML code</b>
<?php 
else:
?>
<b>This is different HTML code</b>
<?php endif; ?>
This uses the PHP alternate syntax to make things a little cleaner: http://php.net/manual/en/control-structures.alternative-syntax.php
For your include example, you don't really need that, just do this:
Code:
if ( $some_condition )
      include ( "/include/some_html.php" );
else
      include ( "/include/some_html_2.php" );
You can include .html files so I don't know why it isn't working, but doesn't matter - just rename your HTML files to PHP files and include those. PHP files don't HAVE to include PHP code.
Another option is the Smarty template engine (much better).

Thanks.

In my experience, smarty has been nothing but a headache :L
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
post #5 of 11
Quote:
Originally Posted by JY View Post

Thanks.
In my experience, smarty has been nothing but a headache :L

That's why I wrote my own template engine smile.gif
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
post #6 of 11
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

That's why I wrote my own template engine smile.gif

? 0.o
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
post #7 of 11
Quote:
Originally Posted by JY View Post

? 0.o

I never liked Smarty much either - so I rolled my own (when I used to do this stuff, that is...)
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
post #8 of 11
Thread Starter 
Quote:
Originally Posted by tompsonn View Post

I never liked Smarty much either - so I rolled my own (when I used to do this stuff, that is...)

Hm, interesting.
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
:3
(10 items)
 
   
CPUMotherboardGraphicsRAM
2600k Asus P8Z77-I Deluxe GTX 680 2GB 16GB Corsair vengeance  
Hard DriveOSMonitorPower
2x 250GB HyperX Windows 7 SP1 x64 Benq G2420HD XFX 650W 
CaseAudio
lian li pc-q08b On-board 
CPUMotherboardGraphicsRAM
phenom II X4 955 C3 @ 4.2ghz 1.4v ASUS M4A79T Deluxe Radeon HD 5870 crossfire 940/1300 8GB corsair ddr3 1600mhz 7-8-7-20@1.75v 
Hard DriveCoolingCoolingOS
120GB Kingston HyperX SSD, 250gb HDD x3 +660Gb 5870 Accelero Xtreme Corsair H100  win 7 ultimate 64bit (stipped to bone) 
MonitorPowerCase
Benq G2420HD XFX Pro 650W (sleeved) (seasonic in disguise) Bitfenix Colossus 
  hide details  
Reply
post #9 of 11
include();
require();
require_once();

Or as said above, for something simple, use if's for the logic then echo the HTML.

Probably more too, I've only been doing PHP for a year.
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8 Professional 
MonitorMonitorMonitorKeyboard
Samsung S22B350H Samsung S22B350H Samsung S22B350H Ducky Shine II 
PowerCaseMouseMouse Pad
Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 Razer Goliathus 
Audio
Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8 Professional 
MonitorMonitorMonitorKeyboard
Samsung S22B350H Samsung S22B350H Samsung S22B350H Ducky Shine II 
PowerCaseMouseMouse Pad
Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 Razer Goliathus 
Audio
Microsoft LifeChat LX 3000 
  hide details  
Reply
post #10 of 11
Quote:
Originally Posted by dushan24 View Post

include();
require();
require_once();

Or as said above, for something simple, use if's for the logic then echo the HTML.

Probably more too, I've only been doing PHP for a year.

 

this is what I did, rather then constantly closing and re-opening PHP code tags, or increasing the number of files on the server, I just made use of the echo command. On a fast enough server, you will not notice a speed difference, not sure if there would really be one anyway.
CHILZ - Lan Rig
(17 items)
 
CANARY - Main Rig
(16 items)
 
CADILLAC - HTPC
(14 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon X3480 Asus Maximus III Gene AMD 7950 Mushkin Redline 2133 MHz CL9 
Hard DriveHard DriveHard DriveCooling
250 GB Samsung 840 120 GB OCZ Solid 3 60 GB OCZ Vertex 2 Custom Loop 
OSMonitorKeyboardPower
Windows 8 Pro BenQ GL2450 Filco MajesTouch2 Ninja PC P&C Silencer Mk III 600 W 
CaseMouseMouse PadAudio
Spotswood Small Tech Station Tt e-Sports Saphira Monoprice XXL Yamaha R-S300 + JVC Bookshelfs 
Other
Scythe Kama-Panel 3 
CPUMotherboardGraphicsRAM
FX-8150 @ 4.6 GHz Fatal1ty 990FX Pro 9800 GTX+ 512 MB G.Skill Ripjaws X 1866 CL9 
Hard DriveHard DriveCoolingOS
120 GB OCZ Vertex 3 1 TB WD Black 5x 120mm + MCP350 + EK Supreme HF + MicroRes Windows 8 Consumer Preview 
MonitorKeyboardPowerCase
2x Dell U2212HM Logitech G110 Cooler Master 850W Silent Pro Cooler Master 690 II Adv. 
MouseMouse PadAudio
Razer Death Adder 3.5G Staples Gel Cushion Asus Xonar DG + Senn. PC333D 
CPUMotherboardGraphicsRAM
Q6600 Acer X1800 ATI 5670 2 GB Kingston 
Hard DriveOptical DriveOSMonitor
2 TB WD Green Asus BD-R Windows 7 Home Premium Sony 50" LCD 
KeyboardPowerCaseMouse
Acer Media 220 W SFF Acer X1800 Acer Optical 
Mouse PadAudio
The TV cabinet Denon 2808 7.1 AVR + Dahlquist 350W 8" Sub + Kl... 
  hide details  
Reply
CHILZ - Lan Rig
(17 items)
 
CANARY - Main Rig
(16 items)
 
CADILLAC - HTPC
(14 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon X3480 Asus Maximus III Gene AMD 7950 Mushkin Redline 2133 MHz CL9 
Hard DriveHard DriveHard DriveCooling
250 GB Samsung 840 120 GB OCZ Solid 3 60 GB OCZ Vertex 2 Custom Loop 
OSMonitorKeyboardPower
Windows 8 Pro BenQ GL2450 Filco MajesTouch2 Ninja PC P&C Silencer Mk III 600 W 
CaseMouseMouse PadAudio
Spotswood Small Tech Station Tt e-Sports Saphira Monoprice XXL Yamaha R-S300 + JVC Bookshelfs 
Other
Scythe Kama-Panel 3 
CPUMotherboardGraphicsRAM
FX-8150 @ 4.6 GHz Fatal1ty 990FX Pro 9800 GTX+ 512 MB G.Skill Ripjaws X 1866 CL9 
Hard DriveHard DriveCoolingOS
120 GB OCZ Vertex 3 1 TB WD Black 5x 120mm + MCP350 + EK Supreme HF + MicroRes Windows 8 Consumer Preview 
MonitorKeyboardPowerCase
2x Dell U2212HM Logitech G110 Cooler Master 850W Silent Pro Cooler Master 690 II Adv. 
MouseMouse PadAudio
Razer Death Adder 3.5G Staples Gel Cushion Asus Xonar DG + Senn. PC333D 
CPUMotherboardGraphicsRAM
Q6600 Acer X1800 ATI 5670 2 GB Kingston 
Hard DriveOptical DriveOSMonitor
2 TB WD Green Asus BD-R Windows 7 Home Premium Sony 50" LCD 
KeyboardPowerCaseMouse
Acer Media 220 W SFF Acer X1800 Acer Optical 
Mouse PadAudio
The TV cabinet Denon 2808 7.1 AVR + Dahlquist 350W 8" Sub + Kl... 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Conditionally including HTML code in PHP?