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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:50:23+00:00 2026-06-05T00:50:23+00:00

I am trying to show images from database with next previous button. here’s my

  • 0

I am trying to show images from database with next previous button.

here’s my code:

<?PHP
session_start();
$page = "voting.php";
include ('dbconnect.php');
$q = "SELECT * FROM vote_frames";
$r = mysql_query($q);
while($row = mysql_fetch_array($r)){
    $i_array[] = $row['frame_pic'];
    $i_array1[] = $row['frame_pic1'];
    $i_array2[] = $row['frame_pic2'];
    $id_array[] = $row['frame_id'];
}
$fpp = 1;
$num_images = count($i_array);
$image_path = "frames/";
$y = $fpp;
if(!isset($_GET['first'])){
        $first = 0;
    }else{
        $first = (int) $_GET['first'];
}
$x = $num_images - 1;
$z = $x - $y;
if($first>$z) {
    $first = $z;
}
$last = $first + $fpp;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
</head>
<body>

<div>
                <?PHP
                $i = $first;
                $prev = $first-1;
                $next = $first +1;
                if($prev<0){ $prev = 0; }
                ?><a href="<?PHP echo $page; ?>?first=<?PHP echo $prev; ?>">Previous</a><?PHP
                while($i<$last) { 
                    $f = $image_path . $i_array[$i];
                    $f1 = $image_path . $i_array1[$i];
                    $f2 = $image_path . $i_array2[$i];
                    ?>
                    <img src="<?PHP echo $f; ?>">
                    <img src="<?PHP echo $f1; ?>">
                    <img src="<?PHP echo $f2; ?>">
                    <?PHP 
                    $i++; 
                }
                ?><a href="<?PHP echo $page; ?>?first=<?PHP echo $next; ?>"><Next</a><?PHP
                ?>

</div>
</body>
</html>

Images are displaying but with a strange behavior that last record is not showing. Actually for testing when I echoed id of current showing record, it shows next’s id so record is having id of next’s.

I know I can do it with jquery w/o any issue but I must use a way to store current showing pic’s id in session so I can show current showing and its next picture’s vote count in the graph below.

Any take on it?

  • 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-05T00:50:25+00:00Added an answer on June 5, 2026 at 12:50 am

    This part here is VERY cryptic, why you have written it that way? I assume you have tested several ways to do it, but … clean up code, while you correct or test it. That way it’s not too cryptic to read.

    $fpp = 1;
    $num_images = count($i_array);
    $image_path = "frames/";
    $y = $fpp;
    if(!isset($_GET['first'])){
            $first = 0;
        }else{
            $first = (int) $_GET['first'];
    }
    $x = $num_images - 1;
    $z = $x - $y;
    if($first>$z) {
        $first = $z;
    }
    $last = $first + $fpp;
    

    And there is your problem too $x is number of images minus one, and $z is $x minus $y (which is one, cryptically yes). Which means $z is number of images minus 2. Thats why last record is not showing. Clean up that code, and it starts working, it would be easy to fix, but I’ll leave it to you as practise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, trying to get images from my SD card to show in an activity
I'm trying to upload images (byte arrays) from the client to a database -
i'm trying to display an image from the database in an ASP.NET web page.
I'm trying to show all images from a selected category on screen. Which is
I'm trying to capture some images from an old database. When writing scrapers, I
I am trying to show two images on Map on base of Points name.
I'm trying to show thumbnail images in Django admin, but I can only see
I trying to use the some plugin for show images in popup window. I
Ok I am trying to show a number using a series of Images. eg.
I have some images stored in getExternalFilesDir() and i am trying to show those

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.