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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:38:57+00:00 2026-05-26T06:38:57+00:00

Currently I created mySQL database with the reference path of images and some additional

  • 0

Currently I created mySQL database with the reference path of images and some additional columns of the database with ID, captions, location etc.

I need to populate a php site with these infomation. An example of the site structure should look like this:

PICTURE (Image with width = 175 height = 200)

Photo taken with Canon Camera (Caption)

Paris (Location)

As you can see, each image should have a caption and location below the picture.

Depending on the mySQL query, all these images retreived from database should be put side by side.

mySQL query is as follows(using php getimage.php):

<?php

$id = $_GET['id'];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("photodb", $link);
$sql = "SELECT photo_path FROM photo WHERE id=$id";
$result = mysql_query($sql, $link);
$row = mysql_fetch_assoc($result);
mysql_close($link);

header("Content-type: image/jpeg");
echo file_get_contents($row['photo_path']);


?>

getcaption.php:

<?php

$id = $_GET['id'];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("photodb", $link);
$sql = "SELECT caption FROM photo WHERE id=$id";
$result = mysql_query($sql, $link);
$row = mysql_fetch_assoc($result);
mysql_close($link);

echo $row['caption'];

?>

I have actually created a css ul with class “grid” for doing this. Currently, my code is as follows:

    <ul class="grid">
        <li>
            <p class="image"><img src="getImage.php?id=1" alt="" width="175" height="200" /></p>
            <p class="caption"></p>
            <p class="location"></p>
        </li>
        <li>
            <p class="image"><img src="getImage.php?id=2" alt="" width="175" height="200" /></p>
            <p class="caption"></p>
            <p class="location"></p>

        </li>

At the moment, I have two issues.

One – How do i display the caption data in the <p> tag?

Two – As you can see, I have defined only two <li> at the moment. What if my query returns more than two results? What if i did a mySQL insert elsewhere? Should i do a loop somewhere?

Thank you for looking at my issues

  • 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-05-26T06:38:58+00:00Added an answer on May 26, 2026 at 6:38 am
    <?php
    
    $link = mysql_connect("localhost", "root", "");
    mysql_select_db("photodb", $link);
    $sql = "SELECT id, caption, location FROM photo";
    $result = mysql_query($sql, $link);
    
    ?>
    <ul class="grid">
    
    <?php while ($row = mysql_fetch_assoc($result)) { ?>
            <li>
                <p class="image"><img src="getImage.php?id=<?php echo $row['id']; ?>" alt="" width="175" height="200" /></p>
                <p class="caption"><?php echo $row['caption']; ?></p>
                <p class="location"><?php echo $row['location']; ?></p>
            </li>
    <?php } // while  ?>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a web application using MYSQL database InnoDB format and need some
I'm currently trying to create a mySQL database that holds hashes such as MD5
I'm currently building a framework that uses a MySQL database. I can't use the
I need to store a very big amount of text in mysql database. It
I am trying to create some pages using PHP / MySQL. My database table
I'm trying to get my models to use my MySQL database. Currently they're not.
I'm currently designing a database (MySQL) for drink recipes and want users to be
Im currently writing a database for a school project. Im using MySQL on xampp
I need to create a table in MySQL which stores the different currency symbols
Currently I have created a ABCFactory class that has a single method creating ABC

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.