close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Included menu corrupts local page display

Thread began 9/30/2010 10:23 am by info97301 | Last modified 10/06/2010 1:40 pm by Jason Byrnes | 1154 views | 8 replies |

info97301

Included menu corrupts local page display

Hi

I have the dynamic menu succesfully working; however, I have tried to include the menu file in a template page; the page immediately displays nothing except

php code block symbol </head> (highlighted in yellow) php code block symbol (shown in attachement!)

I have tried it with <?php include("../menu.php"); ?> (the ; inserted) and that doesn't make any difference.

The page displays properly when viewed on the Internet - but I get a load of errors when trying to check it for W3C compatability - mainly relating to an unfinished head tag, so I'm obviuosly including too much in the file!

ANy suggestions, please?

Cheers
Chris

Sign in to reply to this post

info97301

I've now resolved the </head> problem, by inserting the menu on the template page - not trying to include another page.

However, I still get 9 errors on every page when I try to W3C check - they all relate to

end tag for "ul" which is not finished

I have looked at the code, but it may as well be written in Greek!

TIA
Chris

Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of the template and the menu.php page in a zip archive.

Sign in to reply to this post

info97301

Hi Kason

Thanks for the quick response. Unfortunately, I've lost my WinZip!!

However, I have created almost identical 2 pages - one without the menu, which passes the W3C test and one with, which fails.

W3Cpass.php
W3Cfail.php

Below is the code in the menu.php page

many thanks

Chris
-----------------
<?php
$WA_localRoot = "/";
$WA_remoteRoot = "/";
$WA_curURL = strtolower((isset($_SERVER["PHP_SELF"]))?$_SERVER["PHP_SELF"]:"");
$assumedRoot = $WA_remoteRoot;
if (strpos($WA_curURL,strtolower($WA_localRoot)) == 0 && (strlen($WA_localRoot) >= strlen($WA_remoteRoot) || strpos($WA_curURL,strtolower($WA_localRoot)) === 0)) {
$assumedRoot = $WA_localRoot;
}
$WA_thisFile = $_SERVER['PHP_SELF'];
if (strpos(strtolower($WA_thisFile), strtolower($assumedRoot)) === 0) {
$WA_thisFile = substr($WA_thisFile, strlen($assumedRoot));
}
else {
$WA_thisFile = substr($WA_thisFile, 1);
}
$WA_ddsArray = explode("/", $WA_thisFile);
$WA_dotDotSlash = "";
for ($n=0; $n<sizeof($WA_ddsArray)-1; $n++) {
$WA_dotDotSlash .= "../";
}
?>
<?php
// MenuWriter connection includes
require_once($WA_dotDotSlash . "Connections/connConwy.php");

// end connection includes
// MenuWriter ignore connection includes
if (1 == 0) {
?>
<?php require_once('../../Connections/connConwy.php'); ?>
<?php } // End MenuWriter ignore connection includes ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<ul class="level-0" id="cssmw">
<li class="parent"><a href="<?php echo($assumedRoot); ?>index.php">Home</a>
<ul class="level-1">
</ul>
</li>
<li class="parent"><a href="#">Towns & Villages</a>
<?php
mysql_select_db($database_connConwy, $connConwy);
$query_menuwriter_townsvillages = "SELECT TownID, Town, under_TownID FROM towns_villages WHERE under_TownID IS NULL AND TownActive = 'Y' ORDER BY Town ASC";
$menuwriter_townsvillages = mysql_query($query_menuwriter_townsvillages, $connConwy) or die(mysql_error());
$row_menuwriter_townsvillages = mysql_fetch_assoc($menuwriter_townsvillages);
$totalRows_menuwriter_townsvillages = mysql_num_rows($menuwriter_townsvillages);
?>
<ul class="level-1">
<?php if ($totalRows_menuwriter_townsvillages > 0) { // Show if recordset not empty ?>
<?php do { ?>
<li class="parent"><a href="<?php echo($assumedRoot); ?>towns-in-conwy.php?TownID=<?php echo $row_menuwriter_townsvillages["TownID"]; ?>"><?php echo $row_menuwriter_townsvillages["Town"]; ?></a>
<?php
// MenuWriter Nested Filter Variable
$_POST["menuwriter_townsvillages1_TownID"] = $row_menuwriter_townsvillages["TownID"];
?>
<?php
$MenuWriter_menuwriter_townsvillages1 = "-1";
if (isset($_POST['menuwriter_townsvillages1_TownID'])) {
$MenuWriter_menuwriter_townsvillages1 = (get_magic_quotes_gpc()) ? $_POST['menuwriter_townsvillages1_TownID'] : addslashes($_POST['menuwriter_townsvillages1_TownID']);
}
mysql_select_db($database_connConwy, $connConwy);
$query_menuwriter_townsvillages1 = sprintf("SELECT TownID, Town, under_TownID FROM towns_villages WHERE under_TownID = %s AND TownActive = 'Y' ORDER BY Town ASC", GetSQLValueString($MenuWriter_menuwriter_townsvillages1, "int"));
$menuwriter_townsvillages1 = mysql_query($query_menuwriter_townsvillages1, $connConwy) or die(mysql_error());
$row_menuwriter_townsvillages1 = mysql_fetch_assoc($menuwriter_townsvillages1);
$totalRows_menuwriter_townsvillages1 = mysql_num_rows($menuwriter_townsvillages1);
?>
<ul class="level-2">
<?php if ($totalRows_menuwriter_townsvillages1 > 0) { // Show if recordset not empty ?>
<?php do { ?>
<li><a href="<?php echo($assumedRoot); ?>towns-in-conwy.php?TownID=<?php echo $row_menuwriter_townsvillages1["TownID"]; ?>"><?php echo $row_menuwriter_townsvillages1["Town"]; ?></a></li>
<?php } while ($row_menuwriter_townsvillages1 = mysql_fetch_assoc($menuwriter_townsvillages1)); ?>
<?php } // Show if recordset not empty ?>
</ul>
<?php
mysql_free_result($menuwriter_townsvillages1);
?>
</li>
<?php } while ($row_menuwriter_townsvillages = mysql_fetch_assoc($menuwriter_townsvillages)); ?>
<?php } // Show if recordset not empty ?>
</ul>
<?php
mysql_free_result($menuwriter_townsvillages);
?>
</li>
<li class="parent"><a href="<?php echo($assumedRoot); ?>listings_Search.php">Search & Listings</a>
<?php
mysql_select_db($database_connConwy, $connConwy);
$query_menuwriter_listtype = "SELECT LT_ID, ListType FROM list_type ORDER BY LT_ID ASC";
$menuwriter_listtype = mysql_query($query_menuwriter_listtype, $connConwy) or die(mysql_error());
$row_menuwriter_listtype = mysql_fetch_assoc($menuwriter_listtype);
$totalRows_menuwriter_listtype = mysql_num_rows($menuwriter_listtype);
?>
<ul class="level-1">
<?php if ($totalRows_menuwriter_listtype > 0) { // Show if recordset not empty ?>
<?php do { ?>
<li><a href="<?php echo($assumedRoot); ?>listings.php?lt=<?php echo $row_menuwriter_listtype["LT_ID"]; ?>"><?php echo $row_menuwriter_listtype["ListType"]; ?></a></li>
<?php } while ($row_menuwriter_listtype = mysql_fetch_assoc($menuwriter_listtype)); ?>
<?php } // Show if recordset not empty ?>
</ul>
<?php
mysql_free_result($menuwriter_listtype);
?>
<?php
mysql_free_result($menuwriter_listings);
?>
</li>
<li class="parent"><a href="<?php echo($assumedRoot); ?>tours.php">Tours</a>
<?php
mysql_select_db($database_connConwy, $connConwy);
$query_menuwriter_listings = "SELECT ListID, ListName, ListType FROM listings WHERE ListType=6";
$menuwriter_listings = mysql_query($query_menuwriter_listings, $connConwy) or die(mysql_error());
$row_menuwriter_listings = mysql_fetch_assoc($menuwriter_listings);
$totalRows_menuwriter_listings = mysql_num_rows($menuwriter_listings);
?>
<ul class="level-1">
<?php if ($totalRows_menuwriter_listings > 0) { // Show if recordset not empty ?>
<?php do { ?>
<li><a href="<?php echo($assumedRoot); ?>listingdetails.php?ListID=<?php echo $row_menuwriter_listings["ListID"]; ?>"><?php echo $row_menuwriter_listings["ListName"]; ?></a></li>
<?php } while ($row_menuwriter_listings = mysql_fetch_assoc($menuwriter_listings)); ?>
<?php } // Show if recordset not empty ?>
</ul>
</li>
<li><a href="<?php echo($assumedRoot); ?>activities.php">Things to do</a></li>
<li><a href="<?php echo($assumedRoot); ?>registration.php">Register</a></li>
<li><a href="<?php echo($assumedRoot); ?>contact.php">Contact</a></li>
<li><a href="<?php echo($assumedRoot); ?>login.php">Log In</a></li>
</ul>
<script type="text/javascript">if(window.attachEvent) { window.attachEvent("onload", function() { cssmw.intializeMenu('cssmw',{select_current: 0, orientation: 1}); }); } else if(window.addEventListener) { window.addEventListener("load", function() { cssmw.intializeMenu('cssmw',{select_current: 0, orientation: 1}); }, true); }</script>

Sign in to reply to this post

Jason ByrnesWebAssist

the issue is occurring because the recordsets for some of the dynamic elements in your map are not returning results, this is causing <ul> tags to be started, but no <li> tags are in them which is causing the w3c validation to fail

<li class="parent"><a href="/towns-in-conwy.php?TownID=7">Colwyn Bay</a>
<ul class="level-2">
</ul>
</li>




once the database is properly populated with data, it will not fail validation.

Sign in to reply to this post

info97301

Hi Jason

Thanks for that - it is the sub menu - some of the main menu items don't have a submenu and others do. Is there a way of adding a 'don't display if emptty' bit of code?

Cheers

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to rearrange the code slightly. for example, the code for the second level may look like:

php:
<ul class="level-1">

<?php if ($totalRows_menuwriter_listings 0) { // Show if recordset not empty ?>
<?php 
do { ?>
<li><a href="<?php echo($assumedRoot); ?>listingdetails.php?ListID=<?php echo $row_menuwriter_listings["ListID"]; ?>"><?php echo $row_menuwriter_listings["ListName"]; ?></a></li>
<?php } while ($row_menuwriter_listings mysql_fetch_assoc($menuwriter_listings)); ?>
<?php 
// Show if recordset not empty ?>
</ul>



rearrange this so the ul tags are inside the if statement:

php:
<?php if ($totalRows_menuwriter_listings 0) { // Show if recordset not empty ?>

<ul class="level-1">
<?php do { ?>
<li><a href="<?php echo($assumedRoot); ?>listingdetails.php?ListID=<?php echo $row_menuwriter_listings["ListID"]; ?>"><?php echo $row_menuwriter_listings["ListName"]; ?></a></li>
<?php } while ($row_menuwriter_listings mysql_fetch_assoc($menuwriter_listings)); ?>
</ul>
<?php // Show if recordset not empty ?>
Sign in to reply to this post

info97301

Thanks Jason - it's sorted now (using a 'show region if' behaviour).

Thanks for your perseverence.
Cheers
Chris

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...