no matter what you enter as the # in the ?page=# or whatever it only displays the first 20 rows. what i trying to do is get it spit the date up in groups of 20 rows
link to site:
Site
Page code:
<?php
if (isset($_GET["page"])) {
$page = $_GET["page"];
} else { $page=1; };
$start_from = ($page-1) * 20;
require_once "header.php";
?>
<div id="wrapper">
<!-- Begin Header -->
<div id="header">
This is the Header
</div>
<div id="navigation">
<? echo show_navibar(); ?>
</div>
<div id="faux">
<div id="leftcolumn">
<table id="gradient-style" summary="Meeting Results">
<thead>
<tr>
<th scope="col">Studio</th>
<th scope="col">Website</th>
<th scope="col">English Website</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4"></td>
</tr>
</tfoot>
<tbody>
<? foreach (getStudios() as $studio) {
echo "<tr>"
. "<td>" . htmlspecialchars($studio['Company']) . "</td>"
. "<td>" . htmlspecialchars($studio['Website']) . "</td>"
. "<td>" . htmlspecialchars($studio['EngWebsite']) . "</td>"
. "</tr>";
}
?>
</tbody>
</table>
<?php
$pagelink='<table cellpadding="0" cellspacing="0" align="center"><tr><td align="center">';
if($page>1) $pagelink .='<a href="studios.php?page=1">First</a> ';
if($page>1) $pagelink .='<a href="studios.php?page='.($page-1).'">Prevous</a> ';
$pagelink .='Page '.$page.' ';
if($page<countStudios()) $pagelink .='<a href="studios.php?page='.($page+1).'">Next</a> ';
f($page<countStudios()) $pagelink .='<a href="studios.php?page='.countStudios().'">Last</a>';
$pagelink .='</td><td align="center">Total '.countStudios().' pages.</td></tr>';
$pagelink .='</table>';
echo $pagelink; ?>
</div>
<div id="rightcolumn">
<?php include "login.php"; ?>
<div class="clear"></div>
</div>
</div>
<?php
require_once "footer.php";
?>
Functions called:
function getStudios($start_from) {
$query = "SELECT Company , Website , EngWebsite FROM studio LIMIT". $start_form." 20";
$result = mysql_query($query) or die(mysql_error());
$studios = array();
while ($row = mysql_fetch_assoc($result)) {
$studios[] = $row;
}
return $studios;
}
function countStudios() {
$sql = "SELECT COUNT(Company) FROM studio";
$rs_result = mysql_query($sql);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records / 20);
return $total_pages;
}