שלום, עשיתי חלוקה לעמודים
עכשיו הוא מדפיס ומחלק לעמודים [= אבל לא מחלק שווה בשווה
בדף הראשון הוא שם 18 למרות שקבעתי לו 25 \=
ויש דפים שהוא כן מדפיס 25
מהי הסיבה? :S
הקובץ:
PHP קוד:
<?php
include ("config.php");
$page = (int) $_GET['page'];
if($page < 1 OR !$page)
{
$page = 1;
}
$per_page = 25; // results per page
$start = $per_page * ($page-1);
$query = mysql_query("SELECT * FROM server ORDER BY id DESC LIMIT ".$start.", ".$per_page." ");
while ($row = mysql_fetch_array($query))
{
$active = $row['active'];
$clanpub = $row['cp'];
if ($active == 'פעיל'){
// Setting vars\html block.
if ($clanpub == 'public' OR $clanpub == 'clan')
{
$rid = htmlspecialchars($row['id']);
$rname = htmlspecialchars($row['name']);
$rip = htmlspecialchars($row['ip']);
$rcp = htmlspecialchars($row['cp']);
$rnop = htmlspecialchars($row['nop']);
$rdate = htmlspecialchars($row['date']);
// Done! Print page
echo <<<html
<tr>
<td align=center height="11" style="border-left-style: solid; border-left-width: 1; border-bottom-style: solid; border-bottom-width: 1">{$rid}</td>
<td align=center height="11" style="border-bottom-style: solid; border-bottom-width: 1">{$rname}</td>
<td align=center height="11" style="border-bottom-style: solid; border-bottom-width: 1">{$rip}</td>
<td align=center height="11" style="border-bottom-style: solid; border-bottom-width: 1">{$rcp}</td>
<td align=center height="11" style="border-bottom-style: solid; border-bottom-width: 1">{$rnop}</td>
<td align=center height="11" style="border-right-style: solid; border-right-width: 1; border-bottom-style: solid; border-bottom-width: 1">{$rdate}</td>
</tr>
html;
}}
}
echo <<<html
</table>
html;
$q = mysql_num_rows(mysql_query("SELECT * FROM `server`"));
$total_pages=ceil($q / $per_page);
$pages = array();
for($i = 1; $i <= $total_pages; $i++)
{
if($i == $page)
{
$pages[] = '<b><font color="#FFFFFF">' . $i . '</font></b>';
}
else
{
$pages[] = "<a href = \"print_server.php?page=$i\">$i</a>";
}
}
echo implode(', ' , $pages);
?>