Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8648505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:19:44+00:00 2026-06-12T13:19:44+00:00

My database has 2 tables category and article , Category id | Category ———————

  • 0

My database has 2 tables “category” and “article” ,

Category

id | Category
---------------------
 1   Mobiles
 2   Computers
--------------------
Article


id | Category    | title   |article   
-------------------------------------
 1   2      title      article desc   
 2   1     title      article desc
 3   1     title      article desc
 4   1     title      article desc
 5   2     title      article desc


--------------------------------------

My generated url for articles pages is in this format.

URL/ID/TITLE

I would like to show the next and previous articles titles in the current articles page .

so i used the below code to show the next and previous title with link.

Previous article

$getid = $_GET['id'];
$previous = $getid - 1;
$previousdata = $db->getRow("select * from article WHERE news_id='$previous'");

Next article

$getid = $_GET['id'];
$next = $getid + 1;
$nextdata = $db->getRow("select * from article WHERE news_id='$next'");

And php code like

<a href="http://www.domain.com/article-<?php echo ($previousdata['news_id']); ?>/<?php  echo friendlyURL($previousdata['title']); ?>"> <?php echo  friendlyURL($previousdata['title']); ?></a>

This works fine,It shows the mobiles and computers posts in next and previous links using the id’s,

if i post 2 articles in mobiles category the generated id was 12 and 13 for example, and next if i post an article in computer category the generated id was 14. when the user reading mobile article of id 13 ,at bottom it shows previous article title with id 12 and next article title with id of 14 . Obviously the previous article is mobile and next is computers categories.

But i would like to show only the next and previous pagination with “mobiles” category only,

So i try to assign the category

 $getid = $_GET['id'];
 $next = $getid + 1;
 $nextdata = $db->getRow("select * from article WHERE Category=1 AND id='$next'");

This doesn’t filter only mobile ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:19:45+00:00Added an answer on June 12, 2026 at 1:19 pm

    You can directly get it from query as below

    $getid = $_GET['id'];
    $nextdata = $db->getRow("select * from article WHERE Category=1 AND news_id > ".$getid." order by news_id ASC LIMIT 0,1");
    
    $previousdata = $db->getRow("select * from article WHERE Category=1 AND news_id < ".$getid." order by news_id DESC LIMIT 0,1");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a SQL Server 2008 database. This database has two tables. Book
I have two tables in my database - Category and Food. Food has idCategory.
I have three database tables: Story Id Title Content Category Id Title StoryCategory StoryId
I have two tables in my database: categories id category message messages id title
I have a database table of events. Each event has a category and a
Database has tables Photos and PhotoAlbums. I need a query that will select all
My database has 7 tables: one is the parent (feeds) and the other 3
I have a database that has 16 tables, but only four are relevant to
I have an oracle 10g database that has 2 tables: a REBATES table, and
One of my tables in my SQL database has a growth rate of two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.