0

私のニュースフィードの div は、2 ページ目で閉じています。最初のページで動作し、2 番目のページで終了する理由がわかりません。問題はwww.robhorlacher.ca/RobNews.phpで確認できます。最初のページは正しく、2 番目のページには問題があります。

これはスクリプトです:

 <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;
}

私はこれに1日苦労しているので、これについて何か助けていただければ幸いです。

4

2 に答える 2

2

一見すると、1 つのページ (while ループ内) で一意でない要素 ID を生成しています。これにより、無効な html が生成されます。このトピックを参照してください。詳細については最初の回答ですcss div id はページごとに 1 回だけ使用されます

于 2012-08-31T17:15:00.003 に答える
0

2 番目のページでは、ニュースフィードの div が開くとすぐに閉じられます。これにより、件名バーとニュースコンテンツの div がその外側に残るため、スタイルはそれらに適用されません。私のお勧めは、ブラウザにあるデバッグ ツール (Internet Explorer にも優れたツールがあります) を使用する方法を学ぶことです。F12 キーを押してアクセスできます。

于 2012-08-31T17:14:12.940 に答える