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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.