On the home page of my website, I have 10 news items. I also have an Archives page that shows all the news items I've ever posted...
How do I set it so that on the Archives page, it does not show the 10 news items from the home page? It only shows news item 11, 12, 13 etc etc...
I'm using PHP and MySQL Database.
Thanks
Ben
Selecting old database records
Moderator: General Moderators
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
If you're displaying all rows on a single page, maybe the simplest way to do it is to get the total number of records in the table, and place a limit clause at the end of the select query
Code: Select all
$sql = "SELECT .... LIMIT 10, " . $totalRecords-10;What if I was displaying them in pages? I can get the page part to work, I just need the SQL...
Here is the PHP i would use for the pages...
Thanks Aaron!
Here is the PHP i would use for the pages...
Code: Select all
$Spagecut = "10";
$pageid = $_GET[page];
$page_num = ceil($query_rows / $Spagecut);
$pageid = ($pageid) ? $pageid : 1;
$vstart = $Spagecut * ($pageid-1);
$page_start = floor(($pageid-1)/ $Sdirectcut ) * $Sdirectcut ;
$page_end = $page_start + $Sdirectcut;
etc...
$query = mysql_query("select * from table limit $vstart,$Spagecut") or die(mysql_error());