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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:19:50+00:00 2026-06-13T03:19:50+00:00

Having some issues, basically I have a random image gallery. This is the code

  • 0

Having some issues, basically I have a random image gallery.

This is the code for the random thumbnails:

<?php
include('../../connect.php');
$result = mysql_query("SELECT *
                       FROM picture AS r1
                       JOIN
                       (
                          SELECT ROUND(RAND() * (SELECT MAX(id)
                                                 FROM picture) ) AS id
                       ) AS r2 
                       WHERE r1.id >= r2.id 
                          AND public_approved=1
                       ORDER BY r1.id ASC 
                       LIMIT 4;")
or die(mysql_error());

while($row = mysql_fetch_array( $result ))  
{
echo "<div style='float:left; margin:2px;' >";
echo '<a href="pictures.php?id=' . $row['id'] .'"><img src="../../files/small/thumb0_'. $row['file_name'] . '.' . $row['file_extension'] . '" border="0"></br>';
echo "</div>";
}
?>

When one of the thumbnails is clicked the page reloads and uses the following command to load the main content:

<?php
include('../../connect.php');

$passed_id = $_GET['id']; 

$result1 = mysql_query("SELECT * FROM picture where id='$passed_id' ")
  or die(mysql_error());

while($row = mysql_fetch_array( $result1 ))     
{?>

This continues on through a table displaying the larger image and title and so on.

I’m experiencing two problems:

1 – Even though I specify 4 in the limit, sometimes only 1 2 or 3 thumbs are displayed.

2 – Sometimes when I click on a thumbnail the wrong id is used, i.e. thumbnail id 2 but firing id 8.

  • 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-13T03:19:52+00:00Added an answer on June 13, 2026 at 3:19 am

    Suppose X is the number of images you want to display, you should really take [MAX(id) – X] as the RAND() multiplier. This way the result set will have enough results.

    Second problem seems simple, someone will probably post a good answer, but keep in mind it’s usually a column/parameter confusion in your php/html code.

    Good luck!

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

Sidebar

Related Questions

Ok I am still having some issues with this code below. I have received
Having some issues getting this MPMoviePlayerViewController to work. I have two sample URLs pointing
I am having some trouble with this. We basically have been asked to create
I'm having some concurrency issues with a webpage I'm building. Basically, I have three
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
Hi I'm having some issues understanding how MVC 3 and razor work. Basically, I
I am having some issues passing commands through to flash from javascript. My code
I'm having some issues to deserialize a Json array that follows this format: [
I am having some issues with a code that is occasionally and sporadically throwing
I'm having some issues getting file uploads to work correctly and the following code

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.