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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:10:26+00:00 2026-06-14T07:10:26+00:00

I must be doing something wrong here. It doesn’t work like it should but

  • 0

I must be doing something wrong here. It doesn’t work like it should but its a simple task that serves only one purpose, display the photos from my ./images and ./thumbnails folder to my PHP web form. It is not fully finished but I would just like to get the functionality of being able to see my displayed photos on my page.

Image name are the same in both folders, size is different. Here are some sample photo names in the two folders. IMG786_3, IMG3413, IMG31.

Here is the query to my database in which it retrieves all the title, description, and file name of all photos stored in my database. I put them into an array so I can access them based on an index.

$imgQuery = "SELECT FileName, Title, Description FROM PICTURE WHERE OwnerID='$id' LIMIT 0,7";   
if($imgResult = mysqli_query($link, $imgQuery))
{
while($imgRow = mysqli_fetch_row($imgResult))
{
    $filename[] = $imgRow[0];
    $title[] = $imgRow[1];
    $description[] = $imgRow[2];
}
}

Below is the code that is supposed to display these strings of photos from the two folders I have. When I click on a thumbnail, it is suppose to bring that full size image from the ./images folder and the entire index of the filename, description, and title will change.

print <<<photo
<body>
<span> <?php echo $error; ?> </span>
<form action='MyAlbum.php' method='post'>
    <table>
        <tr><td colspan='7' ><h2 align='center'>$name's Album</h2></td>
        </tr>
        <tr><td colspan='7' >$title[$i]</td>
        </tr>
        <tr><td colspan='5' ><img src="./images/$filename[$i]" /></td><td colspan='2'>$description[$i] </td>
        </tr>
        <tr>
            <td><img src="./thumbnails/$filename[0]" /></td> <td><img src="./thumbnails/$filename[1]" /></td> <td><img src="./thumbnails/$filename[2]" /></td> 
            <td><img src="./thumbnails/$filename[3]" /></td><td><img src="./thumbnails/$filename[4]" /></td> <td><img src="./thumbnails/$filename[5]" /></td> 
            <td><img src="./thumbnails/$filename[6]" /></td> 
        </tr>
    </table>
</form>
</body>
</html>

photo;
  • 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-14T07:10:27+00:00Added an answer on June 14, 2026 at 7:10 am

    Your heredoc is wrong.
    1st – You should iterate over file name to get the thumbnails.
    2nd – you are getting images with variable $i which looks like an iterator but no for loop present.

    I have modified the heredoc into html which works. You will still need javascript/jquery(i prefer) to achieve your image replacement to work. By default when the page loads the first image is displayed.

    <html>
    <body>
    <span> <?php //echo $error; ?> </span>
    <form action='MyAlbum.php' method='post'>
        <table border="1">
            <tr><td colspan='7' ><h2 align='center'><?php echo $name ?>'s Album</h2></td>
            </tr>
            <tr><td colspan='7' >
                <?php echo $title[0]; ?></td>
            </tr>
            <tr>
                <td colspan='5' ><img src="./images/<?php echo $filename[0] ?>" /></td>
                <td colspan='2' ><?php echo $description[0]; ?></td>
            </tr>
            <tr>
             <?php foreach($filename as $f): ?>   
                <td><img src="./thumbnails/<?php echo $f ?>" /></td>
             <?php endforeach; ?>
            </tr>
        </table>
    </form>
    </body>
    </html>
    

    One more thing. using 3 different arrays is not efficient. 1 associative array can achieve this work fine. Lemme know if you have doubts.

    Dins

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

Sidebar

Related Questions

There must be something obvious that I'm doing wrong, but I'm not seeing it.
I must be doing something wrong here but I can't find an easy way
I must be doing something wrong here. I'm trying to use Google Analytics to
I must be doing something wrong here (because really, what are the chances of
I find this very strange, must be something I'm doing wrong, but still... I'm
So I must be doing something wrong here, just not sure what it is
I must be doing something really wrong, but I can't find anything on this
Help me out here, I must be doing something wrong, The first example here
I'm facing a apparently very strange problem (I must be doing something wrong, just
This is a very simple issue. I must just be doing something stupid: This

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.