我的新闻提要div正在第二页关闭。我不知道为什么它会在第一页上工作而在第二页上关闭。.您可以在www.robhorlacher.ca/RobNews.php上查看问题。第一页是正确的,第二页是有问题。

这是脚本:

 <div id="newsfeed">

    <?php

    $hostname = '####';
    $username = '####';
    $password = '####';

    $connection = mysql_connect($hostname, $username, $password)
    or die ('Connection error!!!');

    $database = '####';
    mysql_select_db($database);

    $execute_statement9 = "SELECT COUNT(*) FROM NewsFeed";

    $results9 = mysql_query($execute_statement9) or die ('Error executing SQL statement9!!!');

    $entries =  mysql_fetch_row($results9);

    $rownumber = $entries[0];

    $totalperpage = 8;

    $totalpages = ceil($rownumber / $totalperpage);

    if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {

        $currentpage = (int) $_GET['currentpage'];

    } else {

        $currentpage = 1;
    }

    if ($currentpage > $totalpages) {

        $currentpage = $totalpages;
    }

    if ($currentpage < 1) {

        $currentpage = 1;

    }

    $offset = ($currentpage - 1) * $totalperpage;


        $execute_statement = "SELECT * FROM NewsFeed ORDER BY ID DESC LIMIT $offset, $totalperpage";

        $results = mysql_query($execute_statement) or die ('Error executing SQL statement12!!!');

            while ($row = mysql_fetch_array($results)) {

            $ID = $row["ID"];
            $datetime = $row["DateTime"];
            $indicator = $row["TID"];
            $tabletype = $row["Table"];


        if ($tabletype == "Web") {

    $execute_statement2 = "SELECT * FROM Websites WHERE WID = $indicator";

                $results2 = mysql_query($execute_statement2) or die ('Error executing SQL statement2!!!');


                while ($row2 = mysql_fetch_array($results2)) {

                $wid = $row2["WID"];
                $wname = $row2["Title"];
                $wdescription = $row2["Description"];
                $wextension = $row2["URL"];
                $wimage = $row2["Image"];
        print "<div id=\"subjectbar\">";
        print " <div id=\"topsubject\"></div>";

        print "<div id=\"subject\">";
        print $wname;
        print "</div>";

        print "<div id=\"belowsubject\"></div>";
        print "</div>";

        print "<div id=\"newscontent\">";
        print "<div id=\"wimage\">";
        print "<br>";

        print "<img src = \"uploads/$wimage\" width=\"auto\" height=\"350\">";
        print "</a>";
        print "</div>";
        print "<div id=\"dscimage\">";
        print $wdescription;
        print "<br>";
        print "<br>";
        print "<div id=\"wlink\">";
        print "<a href=\"$wextension\">";
        print " Go to Website";
        print "</a>";
        print "</div>";
        print "<br>";
        print "<br>";
        print "</div>";

        print "</div>";

                }
        }

        else if ($tabletype == "Video") {
            $execute_statement3 = "SELECT * FROM Video WHERE ID = $indicator";

            $results3 = mysql_query($execute_statement3) or die ('Error executing SQL statement3!!!');

                    while ($row3 = mysql_fetch_array($results3)) {

                    $vid = $row3["ID"];
                    $vname = $row3["Name"];
                    $vdescription = $row3["Description"];
                    $vextension = $row3["Extensions"];
                    $vimage = $row3["Image"];


        print "<div id=\"subjectbar\">";
        print " <div id=\"topsubject\"></div>";

        print "<div id=\"subject\">";
        print $vname;
        print "</div>";

        print "<div id=\"belowsubject\"></div>";
        print "</div>";

        print "<div id=\"newscontent\">";
        print "<div id=\"vimage\">";
        print "<br>";
        print "<img src = \"uploads/$vimage\" width=\"auto\" height=\"350\">";
        print "</a>";
        print "</div>";
        print "<div id=\"vdescription\">";
        print $vdescription;
        print "<br>";
        print "<br>";
        print "<div id=\"vlink\">";
        print "<a href=\"http://www.youtube.com/v/";
        print $vextension;
        print "&hl=en&fs=1&rel=0&autoplay=1\" rel=\"shadowbox;width=524;height=344;player=swf\">";
        print " PLAY";
        print "</a>";
        print "<br>";
        print "<br>";
        print "</div>";
        print "</div>";
        print "</div>";
                    }
        }

        else if ($tabletype == "Pictures") {

        $execute_statement4 = "SELECT * FROM ImageAlbums WHERE AlbumID = $indicator";

                $results4 = mysql_query($execute_statement4) or die ('Error executing SQL statement4!!!');

                    while ($row4 = mysql_fetch_array($results4)) {

                    $aid = $row4["AlbumID"];
                    $album = $row4["Album"];

        print "<div id=\"subjectbar\">";
        print " <div id=\"topsubject\"></div>";

        print "<div id=\"subject\">";
        print $album;
        print "</div>";

        print "<div id=\"belowsubject\"></div>";
        print "</div>";

        print "<div id=\"newscontent\">";
        print "<br>";
        print "<div id=\"albmimg\">";
        $execute_statement5 = "Select * FROM Images WHERE AlbumID = $aid LIMIT 3";

        $results5 = mysql_query($execute_statement5) or die ('Error executing SQL statement5!!!');

                            while ($row5 = mysql_fetch_array($results5)) {

                            $imgDscrptn = $row5["Description"];
                            $extns = $row5["Extensions"];

                            print "<div id=\"indvdlimg\">";
                            print "<a href= \"uploads/$extns\" rel=\"shadowbox\">";
                            print "<img src = \"uploads/$extns\" width=\"auto\" height=\"161\">";
                            print "</a>";
                            print "</a>";
                            print "</div>";
                            }
                            print "<div id=\"footerimg\"></div>";
                            print "</div>";
                            print "<div id=\"picviewall\">";
                            print "<a href=\"viewallpictures.php?link=$aid\">";
                            print "- View All";
                            print "</a>";
                            print "<br>";
                            print "<br>";
                            print "</div>";

                    }
            print "</div>";

                }
        }
    print "<div id=\"pagination\">";
    $range = 3;
    print "<br>";
    print "<br>";
    if ($currentpage > 1) {

        print "<a href='{$_SERVER['PHP_SELF']}?currentpage=1'><< </a>";

        }

        for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {

            if (($x > 0) && ($x <= $totalpages)) {

                if ($x == $currentpage) {

                    print "[<b>$x</b>]";

                } else {

                    print "<a href='{$_SERVER['PHP_SELF']}?currentpage=$x'> $x </a>";

                }

            }

        }

    if ($currentpage != $totalpages) {

        $nextpage = $currentpage + 1;

        print "<a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'> > </a>";

        print "<a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'> >> </a>";

    }
    print "</div>";
    ?>
    <br>
    <br>
    <br>
    </div>
    <div id="contentfooter"></div>

    </div>


这是CSS

#content #newsfeed {
    width: 822px;
    float: right;
}

#content #newsfeed #subjectbar {

}

#content #newsfeed #subjectbar #topsubject {
    width: 793px;
    height: 7px;
    background-image: url(../images/topSubjectBar.jpg);
}

#content #newsfeed #subjectbar #subject {
    width: 793px;
    background-image: url(../images/subjectBackground.jpg);
    background-repeat: repeat-y;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 30px;
    color: #FFF;
    padding-top: 30px;
}

#content #newsfeed #subjectbar #belowsubject {
    width: 793px;
    height: 7px;
    background-image: url(../images/bottomSubjectBar.jpg);
}

#content #newsfeed #newscontent {
    width: 793px;
}

#content #newsfeed #newscontent #wimage {
    width: 793px;
    height: 390px;
    text-align: center;
}

#content #newsfeed #newscontent #dscimage {
    width: 793px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    margin-left: 30px;
    margin-right: 30px;
}

#content #newsfeed #newscontent #dscimage #wlink {
    width: 793px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin-left: 50px;
}

#content #newsfeed #newscontent #vimage {
    width: 793px;
    height: 390px;
    text-align: center;
}

#content #newsfeed #newscontent #vdescription {
    width: 733px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

#content #newsfeed #newscontent #vdescription #vlink {
    width: 793px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin-left: 50px;
}

#content #newsfeed #newscontent #albmimg {
    width: 793px;
    height: auto;
    padding-right: 20px;
    padding-left: 20px;
}

#content #newsfeed #newscontent #albmimg #indvdlimg {
    width: 254px;
    height: 190px;
    margin: auto;
    float: left;
    text-align: center;
}

#content #newsfeed #newscontent #albmimg #footerimg {
    width: 793px;
    clear: both;
}

#content #newsfeed #newscontent #picviewall {
    width: 793px;
    height: 40px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin-left: 50px;
}

#content #newsfeed #pagination {
    width: 793px;
    height: 75px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin-left: 50px;
}


我已经为此努力了一天,对此我将不胜感激。

最佳答案

乍一看,您正在一页上(在while循环内)生成非唯一元素id。这导致无效的html。请参考此主题,它是第一个答案,以获取更多详细信息。css div id used only once per page

10-08 13:41