Jump to content

multiple page results.


mattm1712

Recommended Posts

i have done this code but i want to limit to 10 records per page, i cant get the start from and limint number on page correct, it only echos out the links, 1 and 2 i have 18 data inputs in my data base so that bit is corrent by its not echoing the data out please help :)  i think the problem is im my query but cant put my finger on it

 

<?php

include 'connect.inc';

if (isset($_GET["page"]))

{

$page  = $_GET["page"];

}

else

{

$page=1;

};

$start_from = ($page-1) * 10;

$result = mysql_query ("SELECT * FROM images ODER BY date ASC $start_from,10");

$num_rows = mysql_num_rows($result);

echo $num_rows;

?>

<table>

<?php

while ($row = mysql_fetch_assoc($result))

{

?>

            <tr>

            <td><? echo $row['title']; ?></td>

            <td><? echo $row['description']; ?></td>

            </tr>

<?php

};

?>

</table>

<?php

$rs = mysql_query("SELECT COUNT(id) FROM images");

$row = mysql_fetch_row($rs);

$totalrecords = $row[0];

$totalpages = ceil($totalrecords / 10);

 

for ($i=1; $i<=$totalpages; $i++) {

            echo "<a href='hello.php?page=".$i."'>".$i."</a> ";

};

?>

 

thanks matt

Link to comment
https://forums.phpfreaks.com/topic/247374-multiple-page-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.