I want serval pages from 1 to n.how to let the new contennent always on page 1?

Recommended Answers

All 3 Replies

Im assuming your getting the data from a Database. Ill use the example below on PHP/MySQL setup.

You should use something like this;

<?php

$display=10; // The number of records on each page
$start=0;

$query="SELECT COUNT(*) FROM table_name";

$result=mysql_query($query);

$row=mysql_fetch_array($result, MYSQL_NUM);
$num_records=$row[0];

//Calculate # of pages required.
// If the number of returned records is greater than the $display //number then it will create more pages.

if($num_records > $display) {
$num_pages=ceil($num_records/$display);
}else{
$num_pages=1;
}

PLACE HERE YOUR SCRIPT TO QUERY THE DATABASE AND DISPLAY THE RESULTS.

// Here we make the links to other pages
if($num_pages >1) {

echo '<BR/><p>';

//Find what page the script is on
$current_page=($start/$display) +1;

// IF NOT 1st Make a previous button
if($current_page !=1) {
echo '<a href="page_title.php?s='. ($start - $display) .'$np=' . $num_pages.'">Prev</a>';
}

// IF NOT LAST PAGE MAKE A NEXT BUTTON
if($current_page !=$num_pages) {
echo '<a href="page_title.php?s='.($start + $display).'&np='.$num_pages.'">Next</a>';
}
echo '</p>';
}
?>

Hope this helps. PM me if you have any problems.

I don't know asp or php,any other method?

You can either learn PHP or hire someone who knows it. Those are your best options, really.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.