简体   繁体   English

DB html / css显示的500个结果丢失格式后

[英]After 500 results displayed from DB html/css loses formatting

I have a page that runs off a local webserver that is uses SQLite as its database. 我有一个页面运行在使用SQLite作为其数据库的本地网络服务器上。 As its used local I am not worried about listing all results on one page as they load super fast. 作为其使用的本地语言,我不担心将所有结果加载得非常快而在一页上列出所有结果。 I am having an issue with it though as after 500 results are displayed from SQLite3 the formatting goes all wonky and starts stacking them on top of each other. 我有一个问题,尽管在从SQLite3显示500个结果之后,格式变得很奇怪,并开始将它们堆叠在一起。 Everything before that is fine. 之前的一切都很好。 Its written in php. 其用php编写。 Info was entered into the database using htmlspecialchars so I dont believe that is the issue. 信息是使用htmlspecialchars输入到数据库中的,所以我不认为这是问题所在。 The code that builds each record in the loop is 构建循环中每条记录的代码是

$list = '';
while($row = $results->fetchArray()) {
    $id = $row["id"];
    $MovieTitle = $row["MovieTitle"];
    $MovieYear = $row["MovieDate"];
    $MovieRes = $row["MovieRes"];
    $FileName = $row["FileName"];
    $Summary = $row["Summary"];
    $Genres = $row["Genres"];
    $PictureLocation = $row["PictureLocation"];
    $Rating = $row["Rating"];
    $ReleaseDate = $row["ReleaseDate"];

    $list .= '<div class="box">
        <div class="movie">
        <div class="movie-image"><span class="play"><a href="movielist.php?movie='.$FileName.'"><span class="name">'.$MovieTitle.'</span></span><img src="'.$ThumbnailPic.'" alt=""></a></div>
        <div class="rating">
        <p><a href="movie-info.php?movie='.$id.'">RATING: </a>'.$Rating.'</p>
        <div class="stars">
        <div class="'.$StarGraphic.'"></div>
        </div>
        <span class="comments"></span></div>
        </div>';
}

and i just echo them them in the html as such 我只是在html中将它们回显

<html>
    <body>
        <div id="main">
            <br>
            <?php echo $list; ?>
        </div>
    </body>
</html>

Your HTML is wrong, you did not close <div class="box"> and <span class="play"> tags properly. 您的HTML错误,您没有正确关闭<div class="box"><span class="play">标签。

Correct HTML is: 正确的HTML是:

<div class="box">
    <div class="movie">
        <div class="movie-image">
            <span class="play">
                <a href="movielist.php?movie='.$FileName.'">
                    <span class="name">'.$MovieTitle.'</span>
                    <img src="'.$ThumbnailPic.'" alt="">
                </a>
            </span>
        </div>
        <div class="rating">
            <p>
                <a href="movie-info.php?movie='.$id.'">RATING: </a>'.$Rating.'
            </p>
            <div class="stars">
                <div class="'.$StarGraphic.'"></div>
            </div>
            <span class="comments"></span>
        </div>
    </div>
</div>

Aso, you can have some tags or quotes in your database records. 麻生太郎,您可以在数据库记录中包含一些标签或引号。 So you have to use escaping your variables before output http://php.net/manual/en/function.htmlspecialchars.php 因此,您必须在输出http://php.net/manual/en/function.htmlspecialchars.php之前使用转义变量

Something like this: 像这样:

$list = '';
while($row = $results->fetchArray()) {

$id = htmlspecialchars($row["id"]);
$MovieTitle = htmlspecialchars($row["MovieTitle"]);
$MovieYear = htmlspecialchars($row["MovieDate"]);
$MovieRes = htmlspecialchars($row["MovieRes"]);
$FileName = htmlspecialchars($row["FileName"]);
$Summary = htmlspecialchars($row["Summary"]);
$Genres = htmlspecialchars($row["Genres"]);
$PictureLocation = htmlspecialchars($row["PictureLocation"]);
$Rating = htmlspecialchars($row["Rating"]);
$ReleaseDate = htmlspecialchars($row["ReleaseDate"]);

$list .= '<div class="box">
      <div class="movie">
      <div class="movie-image"><span class="play"><a href="movielist.php?movie='.$FileName.'"><span class="name">'.$MovieTitle.'</span></span><img src="'.$ThumbnailPic.'" alt=""></a></div>
      <div class="rating">
      <p><a href="movie-info.php?movie='.$id.'">RATING: </a>'.$Rating.'</p>
      <div class="stars">
      <div class="'.$StarGraphic.'"></div>
      </div>
      <span class="comments"></span></div>
      </div>';

  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM