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 6 of 6
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts

    Exclamation my pageination code doesn't validate please help

    Hi All,

    i have some pagination links on my page but the validator does not like it, it displays ok in the latest IE and firefox browser but im not sure how to make it pass the validator?

    here is my code
    PHP Code:
                echo "<div class='pagination_container'>";
                echo 
    "<ul id=\"pagination-digg\">";
                
    // if not on page 1, don't show back links
                
    if ($currentpage 1)
                {
                    
    // get previous page num
                    
    echo " <li class=\"next\"><a href=$pglink&amp;currentpage=1'>«« First page</a><li> ";
                    
    $prevpage $currentpage 1;
                    
    // show < link to go back to 1 page
                    
    echo " <li class=\"next\"><a href=/&amp;currentpage=" $prevpage .">« Previous</a><li> ";
                } 
    // end if
                
    else
                {
                    
    // get previous page num
                    
    echo " <li class=\"nextdis\">«« First page<li> ";
                    
    $prevpage $currentpage 1;
                    
    // show < link to go back to 1 page
                    
    echo " <li class=\"nextdis\">« Previous<li> ";
                }
            
                
    // loop to show links to range of pages around current page
                
    for ($x = ($currentpage $range); $x < (($currentpage $range) + 1); $x++)
                {
                    
    // if it's a valid page number...
                    
    if (($x 0) && ($x <= $totalpages))
                    {
                        
    // if we're on current page...
                        
    if ($x == $currentpage)
                        {
                            
    // 'highlight' it but don't make a link
                            
    echo " <li class=\"active\">"$x "</li> ";
                            
    // if not current page...
                        

                        else
                        {
                            
    // make it a link
                            
    echo " <li><a href=$pglink&amp;currentpage="$x ">$x</a><li> ";
                        } 
    // end else
                    
    // end if
                
    // end for
                
                // if not on last page, show forward and last page links
                
    if ($currentpage != $totalpages)
                {
                    
    // get next page
                    
    $nextpage $currentpage 1;
                    
    // echo forward link for next page
                    
    echo " <li class=\"next\"><a href=$pglink&amp;currentpage="$nextpage ">Next »</a></li> ";
                    echo 
    " <li class=\"next\"><a href=$pglink&amp;currentpage="$totalpages ">Last page »»</a></li> ";
                } 
    // end if
                
    else
                {
                    
    $nextpage $currentpage 1;
                    
    // echo forward link for next page
                    
    echo " <li class=\"nextdis\">Next »</li> ";
                    echo 
    " <li class=\"nextdis\">Last page »»</li> ";
                }
                echo 
    "</ul>";
                echo 
    "</div>"
    the errors are
    Code:
    document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag
    
    …«« First page<li>  <li class="nextdis">« Previous<li>  <li class="active">1</l…
    Code:
    document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag
    
    …li>  <li class="nextdis">« Previous<li>  <li class="active">1</li>  <li><a hre…
    there is a lot of document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag errors

    if someone could help me solve these i'd be greatful
    thanks

    Luke

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,456
    Thanks
    0
    Thanked 632 Times in 622 Posts
    You are using <li> instead of </li> at the end of each entry and so the validator thinks you are trying to create nested lists.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    LJackson (12-14-2011)

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts
    ah flipping heck cant believe i didnt check that, goes to show that these 'ready made' scripts should be checked before using them

    thanks mate!!!

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts
    one more quick question if i may,

    the url encoding for & => &amp; but is there something similar for the ?

    my above code objects to the questionmark in the links within the li tags...

    the error says
    Code:
    an attribute value must be a literal unless it contains only name characters
    
    …li class="active">1</li>  <li><a href=?bin=dvd&amp;currentpage=2>2</a></li>  <…
    any idea?

    thanks

  • #5
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,332
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by LJackson View Post
    one more quick question if i may,

    the url encoding for & => &amp; but is there something similar for the ?

    my above code objects to the questionmark in the links within the li tags...

    the error says
    Code:
    an attribute value must be a literal unless it contains only name characters
    
    …li class="active">1</li>  <li><a href=?bin=dvd&amp;currentpage=2>2</a></li>  <…
    any idea?

    thanks
    Here's a pretty extensive list of url encoded characters. or this one.
    Teed

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,088
    Thanks
    296
    Thanked 12 Times in 12 Posts
    thanks mate it turns out it wasnt the encoding that i wanted but the ISO 8859-1 Symbols.

    i found them on the w3schools website but there is no question mark, however there i an upside down one??? surely there is a normal one to?

    the iso entity name for the upside down questionmark is &iquest; somaybe just &quest; for the ? will keep looking

    thanks mate


  •  

    Posting Permissions

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