Page 1 of 1

dynamically ganerated menu works only on FF, not IE

Posted: Mon May 25, 2009 2:18 pm
by yosefarnav
Hi guys, hope you can help me somehow...

I wrote a code in PHP to auto generate a html menu.
It works perfectly on FF but nothing happens with IE
Try it out: http://www.yonoacorp.com/clients/aj200/menugen.php

The weird thing is that when I take the php generated code and create a static version (exactly like the generated source) it works in both navigators: http://www.yonoacorp.com/clients/aj200/ ... static.php

I'm using a css/jquery solution provided in this zip file:
http://lwis.net/free-css-drop-down-menu ... v1.0.1.zip


the php code is as follows:

Code: Select all

<?php require_once('Connections/datacon.php'); ?>
 
    <link href="css/dropdown/dropdown.css" media="all" rel="stylesheet" type="text/css" />
    <link href="css/dropdown/themes/default/default.ultimate.css" media="all" rel="stylesheet" type="text/css" />
    
    <!--[if lt IE 7]>
    <script type="text/javascript" src="jscripts/jquery/jquery.js"></script>
    <script type="text/javascript" src="jscripts/jquery/jquery.dropdown.js"></script>
    <![endif]-->    
 
            <!-- inicio drawing do menu-->
            <ul id="nav" class="dropdown dropdown-horizontal">
            
            <!--inicio level 1-->
                
                <?php
                mysql_select_db($database_datacon, $datacon);
                $query_menuset1 = "SELECT * FROM menu WHERE `level` = 1 ORDER BY head ASC";
                $menuset1 = mysql_query($query_menuset1, $datacon) or die(mysql_error());
                $row_menuset1 = mysql_fetch_assoc($menuset1);
                $totalRows_menuset1 = mysql_num_rows($menuset1);
                ?>
                
                <ul>
                <?php do {?>
        
            <!--inicio level 2-->
                
                <?php
                $looker1 = $row_menuset1['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset2 = "SELECT * FROM menu WHERE `head` = $looker1 ORDER BY id ASC";
                $menuset2 = mysql_query($query_menuset2, $datacon) or die(mysql_error());
                $row_menuset2 = mysql_fetch_assoc($menuset2);
                $totalRows_menuset2 = mysql_num_rows($menuset2);
                ?>
                
                <?php if ($totalRows_menuset2 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset1['title']?></span>
                    <ul>
                <?php do { ?>
                
            <!--inicio level 3-->
                
                <?php
                $looker2 = $row_menuset2['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset3 = "SELECT * FROM menu WHERE `head` = $looker2 ORDER BY id ASC";
                $menuset3 = mysql_query($query_menuset3, $datacon) or die(mysql_error());
                $row_menuset3 = mysql_fetch_assoc($menuset3);
                $totalRows_menuset3 = mysql_num_rows($menuset3);
                ?>
                
                <?php if ($totalRows_menuset3 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset2['title']?></span>
                    <ul>
                <?php do { ?>
                
            <!--inicio level 4-->
                
                <?php
                $looker3 = $row_menuset3['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset4 = "SELECT * FROM menu WHERE `head` = $looker3 ORDER BY id ASC";
                $menuset4 = mysql_query($query_menuset4, $datacon) or die(mysql_error());
                $row_menuset4 = mysql_fetch_assoc($menuset4);
                $totalRows_menuset4 = mysql_num_rows($menuset4);
                ?>
                
                <?php if ($totalRows_menuset4 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset3['title']?></span>
                    <ul>
                <?php do { ?>
                
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset4['id']?>"><?php echo $row_menuset4['title']?></a>
                
            <!-- meio level 4 -->
                </li>
                <?php } while ($row_menuset4 = mysql_fetch_assoc($menuset4)); ?>
                </ul>
                <?php } else { ?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset3['id']?>"><?php echo $row_menuset3['title']?></a><?php } ?>
            
            <!--fim level 4-->
                </li>
                <?php } while ($row_menuset3 = mysql_fetch_assoc($menuset3)); ?>
                </ul>
                <?php } else {?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset2['id']?>"><?php echo $row_menuset2['title']?></a><?php } ?>
                
            <!--fim level 3-->
                </li>
                <?php } while ($row_menuset2 = mysql_fetch_assoc($menuset2)); ?>
                </ul>
                <?php } else {?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset1['id']?>"><?php echo $row_menuset1['title']?></a><?php } ?>
                
            <!--fim level 2-->
 
                </li>
                
                <?php } while ($row_menuset1 = mysql_fetch_assoc($menuset1)); ?>
                
                
            <!-- fim level 1-->
            </ul>
            <br style="clear: left" />
            
            <!-- fim drawing do menu-->
 

Re: dynamically ganerated menu works only on FF, not IE

Posted: Tue May 26, 2009 12:55 pm
by mikemike
Two things to try.

First off, add a doctype and proper HTML (ie <html> tags, <body>, <head>, etc) to the dynamic one. FF may assume things that IE does not.

Secondly, and I know how stupid this sounds, but remove some of the comments from the dynamic one. I realise this sounds rediculous but too many comments too frequently can cause IE to not play ball. I've had it happen to me in the passed and there are blog entries on it out there if you look hard enough.

Give those a go and let me know if it works.

Re: dynamically ganerated menu works only on FF, not IE

Posted: Tue May 26, 2009 1:16 pm
by Weirdan
The reason is that it doesn't work (nor should it) in quirks mode. In standards mode (triggered by specifying proper doctype) it works. Static version you have posted contains doctype definition and thus IE renders it in standards mode => it works.

Re: dynamically ganerated menu works only on FF, not IE

Posted: Wed May 27, 2009 3:50 am
by yosefarnav
I did upload a new version for menugen.php with a doctype and now the menu doesn't even show up... (I think it's my fault, i'm checking the code)

I created a new file: menugen-nocoments.php to try the coments stuff without the doctype...

so, by now, nothing worked...

Re: dynamically ganerated menu works only on FF, not IE

Posted: Wed May 27, 2009 4:11 am
by yosefarnav
So, I found out (with your help) what was happening...

In my real page, where I use this menu, I have a doctype and everything else but a few things were out of place...

I inserted the doctype in the menugen.php and it still didn't work, so I changed the places of a few things (that I don't know myself what) and it now works...

For sure it was an issue related to doctype, but not only to doctype, there were a few tags not closed and stuff...

So Thank you very much, try it on your IE&FF now it works on both:
http://www.yonoacorp.com/clients/aj200/menugen.php

the code is as follows:

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php require_once('Connections/datacon.php'); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>menugen with doctype</title>
    <link href="css/dropdown/dropdown.css" media="all" rel="stylesheet" type="text/css" />
    <link href="css/dropdown/themes/default/default.ultimate.css" media="all" rel="stylesheet" type="text/css" />
    
    <!--[if lt IE 7]>

    <script type="text/javascript" src="jscripts/jquery/jquery.js"></script>
    <script type="text/javascript" src="jscripts/jquery/jquery.dropdown.js"></script>
    <![endif]-->
    
</head>
<body>
<div>
            <!-- inicio drawing do menu-->
            <ul id="nav" class="dropdown dropdown-horizontal">
            
            <!--inicio level 1-->
                
                <?php
                mysql_select_db($database_datacon, $datacon);
                $query_menuset1 = "SELECT * FROM menu WHERE `level` = 1 ORDER BY head ASC";
                $menuset1 = mysql_query($query_menuset1, $datacon) or die(mysql_error());
                $row_menuset1 = mysql_fetch_assoc($menuset1);
                $totalRows_menuset1 = mysql_num_rows($menuset1);
                ?>
                
                <?php /* retirado <ul> */?>
                <?php do {?>
        
            <!--inicio level 2-->
                
                <?php
                $looker1 = $row_menuset1['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset2 = "SELECT * FROM menu WHERE `head` = $looker1 ORDER BY id ASC";
                $menuset2 = mysql_query($query_menuset2, $datacon) or die(mysql_error());
                $row_menuset2 = mysql_fetch_assoc($menuset2);
                $totalRows_menuset2 = mysql_num_rows($menuset2);
                ?>
                
                <?php if ($totalRows_menuset2 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset1['title']?></span>
                    <ul>
                <?php do { ?>
                
            <!--inicio level 3-->
                
                <?php
                $looker2 = $row_menuset2['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset3 = "SELECT * FROM menu WHERE `head` = $looker2 ORDER BY id ASC";
                $menuset3 = mysql_query($query_menuset3, $datacon) or die(mysql_error());
                $row_menuset3 = mysql_fetch_assoc($menuset3);
                $totalRows_menuset3 = mysql_num_rows($menuset3);
                ?>
                
                <?php if ($totalRows_menuset3 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset2['title']?></span>
                    <ul>
                <?php do { ?>
                
            <!--inicio level 4-->
                
                <?php
                $looker3 = $row_menuset3['id'];
                mysql_select_db($database_datacon, $datacon);
                $query_menuset4 = "SELECT * FROM menu WHERE `head` = $looker3 ORDER BY id ASC";
                $menuset4 = mysql_query($query_menuset4, $datacon) or die(mysql_error());
                $row_menuset4 = mysql_fetch_assoc($menuset4);
                $totalRows_menuset4 = mysql_num_rows($menuset4);
                ?>
                
                <?php if ($totalRows_menuset4 > 0) {?>
                <li><span class="dir"><?php echo $row_menuset3['title']?></span>
                    <ul>
                <?php do { ?>
                
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset4['id']?>"><?php echo $row_menuset4['title']?></a>
                
            <!-- meio level 4 -->
                </li>
                <?php } while ($row_menuset4 = mysql_fetch_assoc($menuset4)); ?>
                </ul>
                <?php } else { ?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset3['id']?>"><?php echo $row_menuset3['title']?></a><?php } ?>
            
            <!--fim level 4-->
                </li>
                <?php } while ($row_menuset3 = mysql_fetch_assoc($menuset3)); ?>
                </ul>
                <?php } else {?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset2['id']?>"><?php echo $row_menuset2['title']?></a><?php } ?>
                
            <!--fim level 3-->
                </li>
                <?php } while ($row_menuset2 = mysql_fetch_assoc($menuset2)); ?>
                </ul>
                <?php } else {?>
                <li><a href="<?php echo "index.php?type=2&id="; echo $row_menuset1['id']?>"><?php echo $row_menuset1['title']?></a><?php } ?>
                
            <!--fim level 2-->
 
                </li>
                
                <?php } while ($row_menuset1 = mysql_fetch_assoc($menuset1)); ?>
                
                
            <!-- fim level 1-->
            
            <br style="clear: left" />
            </ul>
            <!-- fim drawing do menu-->
</div>
</body>
</html>
<?php
mysql_free_result($menuset1);
mysql_free_result($menuset2);
mysql_free_result($menuset3);
mysql_free_result($menuset4);
?>
 

Re: dynamically ganerated menu works only on FF, not IE

Posted: Wed May 27, 2009 7:18 am
by mikemike
Glad it's sorted. Did you have any issues with comments? I only came across the problem when a framework someone produced in work was overly commented in the HTML and it lead to the pages not being loaded properly in some builds of IE. Note that it didn't seem to be one specific version of IE that did it as it worked on some machines in the office that had the latest IE7 on, but not others with an older IE7 - obviously a bug they fixed.