...

View Full Version : Simple convert html page to php page... problem



Buffmin
01-17-2012, 04:00 PM
Hello. I want to convert a simple html page to php, as I will be doing some mysql coding on the page. Now.... It is a simple page. It only has a vertical nav bar.

To convert it (like step 1), I removed the "doctype" and added a php opening and closing tag at the top of the page (I figured I had to do this to at least make it an official php page!), and saved it as php.

Now.... the nav bar works fine in the index.html page, but on the index.php page the navbar now acts wierd (doesn't completely retract). I don't understand why. I am hoping that someone can help me.
The 2 pages are index.html & index.php
They are both located at http://test.cnjwebsolutions.com/

** You can view the html source code at the link above, but I will attached the php code just for grins. It is the same code as the html, but with no doctype, and has the opening and closing php tags at the top. Thank you very much, Buffmin


<?php
?>
<title>practice</title>


<!-- code for vert nav bar ------->
<link rel="stylesheet" type="text/css" href="ddsmoothmenu.css" />
<link rel="stylesheet" type="text/css" href="ddsmoothmenu-v.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>

</head>
<body>

<div id="smoothmenu2" class="ddsmoothmenu-v">
<ul>
<li><a href="ApacheJunction.php?item=1">Item1</a></li>
<li><a href="#">Folder 0</a>
<ul>
<li><a href="#">Sub Item 1.1</a></li>
<li><a href="#">Sub Item 1.2</a></li>
<li><a href="#">Sub Item 1.3</a></li>
<li><a href="#">Sub Item 1.4</a></li>
<li><a href="#">Sub Item 1.2</a></li>
<li><a href="#">Sub Item 1.3</a></li>
<li><a href="#">Sub Item 1.4</a></li>
</ul>
</li>
</ul>
<br style="clear: left" />
</div>

</body>
</html>

SB65
01-17-2012, 04:25 PM
Both pages work for me in FF9, but I'm betting you're testing in IE...

The difference in behaviour is caused by the absence of the doctype in your .php page. This needs to be reinstated. Without a doctype, IE is quite likely to misbehave itself, which is what I suspect here.

You should just be able to change your index page to have a php extension with no other changes. Once this is done, then any code within <?php...?> tags will be processed as PHP - otherwise, it will just be rendered as text.

You could try this out as an exercise by including the following in your html file, and then changing the extension and retesting:


<?php echo "This is generated by PHP";?>

Buffmin
01-17-2012, 04:59 PM
Cool.
Yep, that was it!, and I was using IE. Thank you very much. Need to keep the doctype. Thanks again! Buffmin (and I did try that) nice.

djh101
01-17-2012, 05:24 PM
PHP pages are still HTML pages, so you still need all the required HTML tags. PHP is a server side language, which means that all the PHP is processed by the server before it is sent to the client/browser. After all the php is processed, the result is then sent to the client as text/html (unless another MIME type is specified in the header).

BluePanther
01-17-2012, 05:26 PM
What wasn't said, which I think should be, is that it's very important to understand the differences between PHP and html.

PHP is server side, html is client side. PHP is executed and parsed before sending to the client, meaning it isn't processed by the browser. html is client side, and is rendered solely by the browser.

The way PHP should work, is it should run, work out what to display, then display it using HTML (maybe through templating, that's your choice). It's not considered great practise to mix both php logic, and html markup, but it can be ok. It is best to follow framework practises like MVC - keeps logic and output separate.

BluePanther
01-17-2012, 05:27 PM
PHP pages are still HTML pages, so you still need all the required HTML tags. PHP is a server side language, which means that all the PHP is processed by the server before it is sent to the client/browser. After all the php is processed, the result is then sent to the client as text/html (unless another MIME type is specified in the header).

And this, beat me to it :P

Buffmin
01-17-2012, 05:46 PM
Thanks guys. I appreciate your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum