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 8051975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:26:13+00:00 2026-06-05T07:26:13+00:00

Possible Duplicate: Previous/next Buttons? how can i make next page and prev page in

  • 0

Possible Duplicate:
Previous/next Buttons?

how can i make next page and prev page in my gallery script ..
when

mid = id of images 
path = link of images 

I need two buttons: next to get next image and prev to get last image. How can i do it ?

$mid=$_GET['mid'];
$qur="select * from images where mid='$mid'";
$res=mysql_query($qur,$conn);
?>
<?php while($row=mysql_fetch_array($res)){ ?>

<div class="gallery-img">
<a href="admin/<?php echo $row['path'] ?>" rel="prettyPhoto" class="portfolio-img" title="<?php echo $row['image_title'] ?>">
<img src="admin/<?php echo $row['path'] ?>" alt="<?php echo $row['image_title'] ?>" width="100%" height="100%" />
</a>
</div>  

<?php } ?>
  • 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-05T07:26:14+00:00Added an answer on June 5, 2026 at 7:26 am

    If you’re using $_GET I’m assuming this would be a dynamic page you go to to view a photo, which you want to show next and prev than on the page, if so than try this

    <?php
    $mid=mysql_real_escape_string($_GET['mid']);
    $res=mysql_query("select * from images where mid='".$mid."'",$conn);
    $prevSQL = mysql_query("SELECT mid, path FROM images WHERE mid > '".$mid."' LIMIT 1");
    $nextSQL = mysql_query("SELECT mid, path FROM images WHERE mid < '".$mid."' LIMIT 1");
    
    $row = mysql_fetch_assoc($res);
    if(mysql_num_rows($prevSQL)>1){
        $prevRow = mysql_fetch_assoc($prevSQL);
        $prev = '<a href="admin/'.$prevRow['mid'].'">Prev</a>';
    } else {
        $prev = 'Prev';
    }
    if(mysql_num_rows($nextSQL)>1){
        $nextRow = mysql_fetch_assoc($nextSQL);
        $next = '<a href="admin/'.$prevRow['mid'].'">Next</a>';
    } else {
        $next = 'Prev';
    }
    ?>
    <div class="gallery-img">
    <a href="admin/<?=$row['path'] ?>" rel="prettyPhoto" class="portfolio-img" title="<?=$row['image_title'] ?>">
    <img src="admin/<?=$row['path'] ?>" alt="<?=$row['image_title'] ?>" width="100%" height="100%" />
    </a>
    <?=$prev.' '.$next;?>
    </div>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: In Perl, how can find the date of the previous Monday for
Possible Duplicate: How can i add more than 10 buttons on a navigationbar in
Possible Duplicate: Emacs, switch to previous window other-window advances me to the next window
Possible Duplicate: What is best solution to get next and previous month from given
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: What does ||= mean? In this previous question, I asked about an
Possible Duplicate: Was: Not unique table :: Now: #1054 - Unknown column - can't
Possible Duplicate: How can I subtract a day from a python date? I have
Possible Duplicate: How to sort by previous date in database? I want to do
Possible Duplicate: Why can’t I catch a generic exception in C#? I have been

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.