我正在制作一个侧边栏提要,它将显示提交到我的数据库中的 10 个最新内容。我对这一切都很陌生,所以我想知道..这是一种可行的方法吗?它可以工作..不是自动的,但是当我将某些内容提交到我的数据库中时,它会在那里..我提交其他内容,然后顶部转到第二个..!我只是无法摆脱这种感觉,也许这不是一个好方法。
前 3 个部分
<div class="span3 offset3">
<?php include 'feed/one.php'; ?>
<ul class="nav nav-list well">
<li class="nav-header"></li>
<li class="active"><a href="#">HIT INFO</a></li>
<?php while($row = $data->fetch_assoc()) { ?>
<li><a href="<?php print $row['link']?>"><?php
Print "<tr>";
Print "<th>Hit:</th> <td>".$row['hit'] . "</td> ";
Print "<th>Amount:</th> <td>".$row['amount'] . " </td>";
Print "<th>Category:</th> <td>".$row['category'] . "</td></tr> ";
Print "<br><br/>";
Print "</table>";?></a></li>
<?php } ?>
<li class="divider"></li>
<?php $data = $mysqli->query("SELECT * FROM hit ORDER BY hit_id DESC LIMIT 1, 1"); ?>
<?php while($row = $data->fetch_assoc()) { ?>
<li><a href="<?php print $row['link']?>"><?php
Print "<tr>";
Print "<th>Hit:</th> <td>".$row['hit'] . "</td> ";
Print "<th>Amount:</th> <td>".$row['amount'] . " </td>";
Print "<th>Category:</th> <td>".$row['category'] . "</td></tr> ";
Print "<br><br/>";
Print "</table>";?></a></li>
<?php } ?>
<li class="divider"></li>
<?php $data = $mysqli->query("SELECT * FROM hit ORDER BY hit_id DESC LIMIT 2, 1"); ?>
<?php while($row = $data->fetch_assoc()) { ?>
<li><a href="<?php print $row['link']?>"><?php
Print "<tr>";
Print "<th>Hit:</th> <td>".$row['hit'] . "</td> ";
Print "<th>Amount:</th> <td>".$row['amount'] . " </td>";
Print "<th>Category:</th> <td>".$row['category'] . "</td></tr> ";
Print "<br><br/>";
Print "</table>";?></a></li>
<?php } ?>
<li class="divider"></li>
<?php $data = $mysqli->query("SELECT * FROM hit ORDER BY hit_id DESC LIMIT 3, 1"); ?>
<?php while($row = $data->fetch_assoc()) { ?>
<li><a href="<?php print $row['link']?>"><?php
Print "<tr>";
Print "<th>Hit:</th> <td>".$row['hit'] . "</td> ";
Print "<th>Amount:</th> <td>".$row['amount'] . " </td>";
Print "<th>Category:</th> <td>".$row['category'] . "</td></tr> ";
Print "<br><br/>";
Print "</table>"; ?></a></li>
<?php } ?>
提交的数据会显示在我的主页上,直到提交其他内容,然后转到“提要”,然后转到显示过去数据的另一个页面。