Lina
Lina

Reputation: 627

HTML validator message: element <li> is not allowed

I have list:

<td ><a href="#"><?php  echo $meniu['lovos']; ?></a>
<ul>
<?php
$result = mysql_query("SELECT baldo_id, kategorija,pavadinimas_lt, pavadinimas_en, pavadinimas_lv, pavadinimas_ru FROM baldas WHERE kategorija = 'sofoslovos'") or die(mysql_error());
        if(mysql_num_rows($result) > 0) {
                while($row = mysql_fetch_assoc($result))
                     {
                 echo'              
                <li><a href="index.php?id=baldas&amp;id2='.$row['baldo_id'].'">';if ($_SESSION['lang']==lt)
                                {echo''.$row['pavadinimas_lt'].'</a>';}
                                elseif ($_SESSION['lang']==en)
                                {echo''.$row['pavadinimas_en'].'</a>';}
                                elseif ($_SESSION['lang']==ru)
                                {echo''.$row['pavadinimas_ru'].'</a>';}
                                elseif ($_SESSION['lang']==lv)
                                {echo''.$row['pavadinimas_lv'].'</a>';}
                                else {echo''.$row['pavadinimas_lt'].'</a>
                </li>';}
    }}?>
</ul>
</td>

HTML code:

<td><a href="#">Komplektai</a>
<ul>        
                <li><a href="index.php?id=baldas&amp;id2=32">yy</a>         
                <li><a href="index.php?id=baldas&amp;id2=33">yy</a>             
                <li><a href="index.php?id=baldas&amp;id2=67">rrr</a>                
                <li><a href="index.php?id=baldas&amp;id2=71">jj</a>   
</ul>
</td>

And when I do validation I keep getting error message:

document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag

But I don't get it. There is both <ul> and <li> elements on my list.

Upvotes: 0

Views: 1980

Answers (2)

marramgrass
marramgrass

Reputation: 1411

Your li elements are only being closed in the final else of the conditional. Make sure they get closed in each case.

Upvotes: 4

Quentin
Quentin

Reputation: 943556

It looks like you are trying to validate a PHP program instead of an HTML document.

Run the program, then validate the HTML it outputs.

(If that isn't the case, then don't show us the PHP, show us the final HTML).

Upvotes: 1

Related Questions