I've been doing some researching and discovered this nice website http://validator.w3.org/
After running a test i see that my navigation get loads of error.
The error i get is the ul in the coding. I don't close it off because i give it it styling if a condition is met else close it.
But this is not a valid solution according to w3 which gives me some errors.
Can you help me find a fix for my navigation so it gets valid?
With thanks Jim
<ul id="nav-container">
<?php
$select_category = mysql_query("SELECT * FROM menu WHERE hidden = 0 ORDER BY menu ASC");
while ($ln = mysql_fetch_array($select_category)) {
$idcat = $ln['nmr'];
$catname = $ln['menu'];
$catsname = str_replace(' ', '-', $ln['menu']);
echo '<li>';
if($catname == "carparts") {
echo '<a href="http://www.mywebsite.com/carparts.php" title="'.$catname.'"><span><strong>'.$catname.'</strong></span></a>';
} else {
echo '<a href="http://www.mywebsite.com/'.$idcat.'/'.$catsname.'/" title="'.$catname.'"><span><strong>'.$catname.'</strong></span></a>';
}
This gives me the errors: (fixed)
echo '<ul';
if(isset($_GET['cats'])) {
if ($_GET['cats'] == $idcat) {
echo ' style="display:block;">';
} else {
echo '>';
}
The fix: also deleted the closing bracket at the end.
echo '<ul';
if(isset($_GET['cats']) && $_GET['cats'] == $idcat){
echo ' style="display:block;">';
} else {
echo '>';
}
/fix finish
//Error finish
$select_sub = mysql_query("SELECT * FROM submenu WHERE nmrmenu = '$idcat' AND hidden = 0");
while ($lsub = mysql_fetch_array($select_sub)) {
$subname = $lsub['submenu'];
$subsname = str_replace(' ', '-', $lsub['submenu']);
$pil = '»';
$brnr = $lsub['nmr'];
if(isset($_GET['cat'])) {
if ($_GET['cat'] == $brnr) {
$subname = '<u>'.$lsub['submenu'].'</u>';
} else {
$subname = $lsub['submenu'];
}
}
echo '<li><a href="http://www.mywebsite.com/'.$lsub['nmr'].'/'.$subsname.'/"><span><strong> '.$subname.' </strong></span></a></li>';
}
echo '</ul>';
echo '</li>'; // to this location
}
echo '</li>'; //relocated this up one line
} **//Deleted this one!**
?>
</ul>
Update
The output gets like this which is horrible: (fixed)
<ul</li><li><a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a>
<ul</li><li><a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a><ul</li>
New: now the ul problem is gone, but it's complaining about the li's. Any clue why?
Error: document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag
<ul id="nav-container">
<li>
<a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a>
<ul>
<li>
<a href="http://www.mywebsite.com/x/name/"><span><strong> name </strong></span></a>
</li>
</ul>
</li>
</ul>
/update