我正在尝试为分页数字添加空格
我的php看起来像这样
echo "<ul class='pagination'>";
echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."' class='button'>Previous</a>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
};
echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
echo "</ul>";
输出看起来有点像
Previous12345678NEXT
如何添加空格?
答案 0 :(得分:0)
echo "<ul class='pagination'>";
echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."' class='button'>Previous</a>";
echo ' ';
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
echo ' ';
};
echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
echo "</ul>";
答案 1 :(得分:0)
尝试以下代码。
<?php
echo "<ul class='pagination'>";
echo "<a style=text-decoration:none href='dashboard.php?page=".($page-1)."' class='button'>Previous </a>";
for ($i=1; $i<=5; $i++) {
echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i." </a>";
};
echo "<a style=text-decoration:none href='dashboard.php?page=".($page+1)."' class='button'>NEXT</a>";
echo "</ul>";
?>
答案 2 :(得分:-1)
如果在网站上使用bootstrap,那么在标签中添加pull-left和pull-right类,例如:
echo "<ul class='pagination'>";
echo "<a style="text-decoration:none" href='dashboard.php?page=".($page-1)."' class='button pull-left'>Previous</a>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
};
echo "<a style="text-decoration:none" href='dashboard.php?page=".($page+1)."' class='button pull-right'>NEXT</a>";
echo "</ul>";
echo "<ul class='pagination'>";
echo "<a style="text-decoration:none; float:left" href='dashboard.php?page=".($page-1)."' class='button'>Previous</a>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style=text-decoration:none href='dashboard.php?page=".$i."'>".$i."</a>";
};
echo "<a style="text-decoration:none; float:right" href='dashboard.php?page=".($page+1)."' class='button '>NEXT</a>";
echo "</ul>";