Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    Simple convert html page to php page... problem

    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 Code:
    <?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>
    Last edited by Buffmin; 01-17-2012 at 04:03 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    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 Code:
    <?php echo "This is generated by PHP";?>

  • Users who have thanked SB65 for this post:

    Buffmin (01-17-2012)

  • #3
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    616
    Thanks
    48
    Thanked 65 Times in 65 Posts
    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).
    "Yeah science!"
    Online Science Tools

  • Users who have thanked djh101 for this post:

    Buffmin (01-17-2012)

  • #5
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    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.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    Buffmin (01-17-2012)

  • #6
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by djh101 View Post
    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
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    Buffmin (01-17-2012)

  • #7
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Thanks guys. I appreciate your help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •