Jump to content

Inserting php code within HTML5 files


kiwigirl

Recommended Posts

I have a assignment I'm working on where we are implementing HTML5 and CSS3 code. Up to this point I have had no major issues. I have finished designing the mobile design and now I am moving to the tablet.

 

The issue is that I need to change the menu so when the browser size is over 480px it will revert to a different html file.

 

So my understanding is if I'm going to use php code I need to change the file name to .php

 

This is where I'm now running into problems. It no longer links any of my images and some of the layout is changed. Also, none of the css are recognised within the index file.

 

So how can I place code into a file without having to change the entire site.

 

This was the code I came up with and hoping to use:

 

<?php

 

 

// Include and instantiate the mobile detect class

include('classes/Mobile_Detect.php');

$detector = new Mobile_Detect();

 

$mobile = $detector;

 

$tablet = $detector;

 

 

 

?>

 

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title>Maria Louisa Dolls - About the Dolls and Creator</title>

<meta name="viewport" content="width=device-width" />

<link rel="stylesheet" href="css/default.css" />

<link rel="stylesheet" href="css/mobile.css" media="only all and (max-width: 480px)" />

<link rel="stylesheet" href="css/tablet.css" media="only all and (min-width: 481px)" />

<link rel="stylesheet" href="css/desktop.css" media="only all and (min-width: 960px)" />

<!--[if lt IE 9 & !IEMobile]>

<link rel="stylesheet" href="css/tablet.css" />

<link rel="stylesheet" href="css/desktop.css" />

<![endif]-->

 

<!--[if lt IE 9]>

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

<![endif]-->

</head>

 

<body>

<nav>

<h1><a href="index.html">M<span id="heading-font">aria </span>L<span id="heading-font">ousia </span>D<span id="heading-font">olls</span></a></h1>

<ul>

<li><a id="greenHyperLink" href="about.html">About</a></li>

 

<?php

$url = 'gallery';

if($mobile) {

$url .= '_mobile';

}

$url .= '.php';

 

echo '<li><a href="' . $url . '">Gallery</a></li>';

 

?>

 

<li><a href="shop.html">Shop</a></li>

<li><a href="contact.html">Contact</a></li>

<li><a href="sitemap.html">Sitemap</a></li>

<li><a href="help.html">Help</a></li>

<li><a href="contact.html">Subscribe</a></li>

</ul>

</nav>

 

I did try to add a zipped file of my website, but it doesn't allow this. I'm a little concerned as this is due on Tuesday, so if any body can help I so will appreciate this. Cheers :)

Link to comment
Share on other sites

How are you trying to run this file? Are you running it on a server -- either FTPing it to a web host, or using something like MAMP or WAMP on your computer to create the server? Simply opening up a .php file in your browser won't work, since PHP needs a server to be able to understand and process PHP code.

 

Besides that potential issue, I'm not really seeing anything that should be an issue, but I may be missing something.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...