Jump to content

PHP, inside of HTML, inside of PHP


eRott

Recommended Posts

Ok, I have a slight problem that I am wondering if someone could help me out with. Like the title says, I want to include a php file, inside of html code, that is inside of more php code. What I mean by that is that if you look at the code below, you will notice $head = " this is a section of a php file. Now this $head variable is just the header of a template. Anyway, thats not the point. To simplify it, the:

Blue = PHP script in the php file
Green = HTML code inside that PHP code
Red = The php file I want to include but am having trouble doing so

[b][color=blue]$head = "[/color][/b]
[color=green]<html>
<head>
<LINK href='../lib/style.css' rel='stylesheet' type='text/css'>
<title>TITLE</title>
</head>
<body>
<center>

<div id='wrapper'>

<div id='topnav'>
<div class='nav'>[/color]
[color=red]<? include('../lib/userlogin.php'); ?>[/color]
[color=green]</div>
</div>

<div id='header'>
<a href='../index.php'><img src='../images/logo.png' border='0' alt='aaa' title='aaa'></a>
</div>

<div id='mainnav'>
<a href='../index.php'><img src='../images/01home.jpg' alt='Home' border='0' height='49' width='191' /></a><a href='../plans.php'><img src='../images/02plans.jpg' alt='Plans' border='0' height='49' width='197' /></a><a href='#'><img src='../images/03forums.jpg' alt='Forums' border='0' height='49' width='201' /></a><a href='#'><img src='../images/04support.jpg' alt='Support' border='0' height='49' width='211' /></a>
</div>

<div id='menu'>[/color]
[color=red]<? include('../admin/lib/nav.php'); ?>[/color]
[color=green]</div>

<div id='content'>

<div class='ads'>
<p><center>[/color][color=red]<? include('../lib/ads.php'); ?>[/color][color=green]</center></p>
</div>[/color]
[b][color=blue]";[/color][/b]

Could anyone please help me out with this problem of how to include a php file, that is inside of html code, that is inside of php script (if its no too confusing :P). Thanks.

(edit: just replace all of the [b]/url[/b] 's you see with [b]/a[/b] 's because this changes them since I couldnt put it in the code tag since it doesnt allow colors.)
Link to comment
https://forums.phpfreaks.com/topic/27596-php-inside-of-html-inside-of-php/
Share on other sites

ok :-) basically speaking...
[code]
$head = "
<html>
<head>
<LINK href='../lib/style.css' rel='stylesheet' type='text/css'>
<title>TITLE</title>
</head>
<body>
<center>

<div id='wrapper'>
<div id='topnav'>
  <div class='nav'>";
include('../lib/userlogin.php');
$head .= "</div>
</div>
<div id='header'>
  <a href='../index.php'><img src='../images/logo.png' border='0' alt='aaa' title='aaa'>[/url]
</div>
<div id='mainnav'>
  <a href='../index.php'><img src='../images/01home.jpg' alt='Home' border='0' height='49' width='191' />[/url]<a href='../plans.php'><img src='../images/02plans.jpg' alt='Plans' border='0' height='49' width='197' />[/url]<a href='#'><img src='../images/03forums.jpg' alt='Forums' border='0' height='49' width='201' />[/url]<a href='#'><img src='../images/04support.jpg' alt='Support' border='0' height='49' width='211' />[/url]
</div>
<div id='menu'>";
include('../admin/lib/nav.php');
$head .= "</div>
<div id='content'>
  <div class='ads'>
  <p><center><? include('../lib/ads.php'); ?></center></p>
  </div>";
[/code]

then in the nav.php etc. have that info also encompased by the "$head .= "
Ok, well, I tried it and it works. Well, sorta. Its included now, but it's not showing up where it's supposed to. I didnt add the "$head .=" to the files being included, because they are also called in different pages, so editing them is not really an option. Any other ideas? And thank you for the help.

(edit: just added it to the other files being included to see what would happen and it does nothing.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.