sbradley85 Posted June 24, 2010 Share Posted June 24, 2010 Hello! I am not sure if this is the correct place to be posting my issue. I would normally just google until finding a solution. Although, in this case I am not even really sure what I should be google-ing. My Issue: I have header.php which contains css formation for a menu that works fine if I browse directly to header.php I am using include('include/header.php') in all of my pages. When I do this I get the menu items, but the css formatting is not applied. Thanks, Shawn Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/ Share on other sites More sharing options...
premiso Posted June 24, 2010 Share Posted June 24, 2010 How is the css formating being displayed, via inline css or a linked css? Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076783 Share on other sites More sharing options...
sbradley85 Posted June 24, 2010 Author Share Posted June 24, 2010 echo '<link rel="stylesheet" href="headerstyle.css" type="text/css" />'; So I guess a linked css? Sorry I am completely new at this. Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076785 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 Please show us the source for header.php and the script you're including it into. Ken Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076800 Share on other sites More sharing options...
sbradley85 Posted June 24, 2010 Author Share Posted June 24, 2010 header.php <?php echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; echo '<html lang="en">'; echo '<head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; echo '<title>PHP Ticket System X</title>'; echo '<meta name="generator" content="Test">'; echo '<meta name="author" content="Shawn Bradley">'; echo '<!-- Date: 2010-06-23 -->'; echo '<link rel="stylesheet" href="menu/menu_style.css" type="text/css" />'; echo '</head>'; echo '<body bgcolor="333333">'; echo '<table cols="2" border="0" cellpadding="10" cellspacing="0" align="center" width="900">'; echo '<tr>'; echo '<td width="400" bgcolor="#333333" valign="top">'; echo '</strong><font face="verdana" size="6" color="ffffff">Ticket System X</font></strong>'; echo '</td>'; echo '<td bgcolor="#333333">'; echo '<div class="menu">'; echo '<ul>'; echo '<li><a href="#" >Home</a></li>'; echo '<li><a href="#" id="current">Something...</a>'; echo '<ul>'; echo '<li><a href="#">Something... DropDown</a></li>'; echo '</ul>'; echo '</li>'; echo '<li><a href="/contact/contact.php">Contact Info</a></li>'; echo '</ul>'; echo '</div>'; echo '</td></tr></table>'; ?> </body> </html> anypage.php <?php echo '<head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; echo '<title>PHP Ticket System X</title>'; echo '<meta name="generator" content="Test">'; echo '<meta name="author" content="Shawn Bradley">'; echo '<!-- Date: 2010-06-23 -->'; echo '</head>'; include ('include/header.php'); $location=$_GET['location']; if (empty($location)) { $location='index'; } changelocation($location); function changelocation($location) { include ('include/header.html'); echo '<table cols="2" border="0" cellpadding="10" cellspacing="0" align="center" width="100%">'; echo '<tr>'; echo '<td width="224" bgcolor="#0099FF" valign="top">'; include('index.php'); echo '</td>'; echo '<td bgcolor="#33CCFF">'; switch ($location) { case 'index': include ('actualindex.html'); break; case 'Content': include ('maincontent.html'); break; } echo '</td></tr></table>'; include ('footer.html'); } ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076809 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 You are repeating the "<head>" section in both the include file and the other pages. Leave it out of the other pages. This duplication could be confusing the browsers. Ken Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076817 Share on other sites More sharing options...
sbradley85 Posted June 24, 2010 Author Share Posted June 24, 2010 Ken, I took the <head> tags out of the page and only left them in the header.php. It did not work. Thanks, Shawn Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076820 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 Do you have a live link to the problem script? Ken Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076828 Share on other sites More sharing options...
sbradley85 Posted June 24, 2010 Author Share Posted June 24, 2010 Ken, I do not. How is this suppose to be done when including a file? It works fine if I browse to the header.php directly? Thanks, Shawn Quote Link to comment https://forums.phpfreaks.com/topic/205773-php-css-help-when-include-other-files/#findComment-1076832 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.