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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:11:00+00:00 2026-05-26T07:11:00+00:00

I have an issue on how to create individual php pages automatically. I have

  • 0

I have an issue on how to create individual php pages automatically.

I have already created a page called catalog.php.

In catalog.php, mySQL query would take place, querying:

$link = mysql_connect("localhost", "root", "");
mysql_select_db("photodb", $link);
$sql = "SELECT id, title, caption, comments, imagelink, year FROM photo";

Then this query would loop and display the contents on catalog.php side by side:

<ul class="grid">
<?php while ($row = mysql_fetch_assoc($result)) 
    { ?>
        <li>
            <p class="image"><a href="?"><img src="getImage.php?id=<?php echo $row['id']; ?>" alt="" width="175" height="200" /></a></p>
            <p class="name"><?php echo $row['title']; ?></p>
            <p class="year"><?php echo $row['year']; ?></p>
        </li>
        <?php } // while  
?>
</ul>

where class=”grid” would arrange all the queried data side by side, with image, title and year being displayed.

However, one requirement that i need is that whenever i click on any of these images, it should link to its own php page(individual.php) to show a detailed image, title, caption and author’s comments. An elaboration is shown below:

           Title
IMAGE      Caption

           Author's comments

An example:

           Picture of bridge
IMAGE      This image was taken in paris

           Low Shuttle Speed

In the above, IMAGE, caption, title, author’s comments are found in the same database “photodb” in the same table “photo”

My issue here is as follows:

  1. Is there a way to create such pages automatically? The reason being is, if I create them manually I would have a hard time because my database has more that 100 entries.

  2. In the <a href=""> tag as seen in catalog.php, what should the values be?

  3. I already have a template for such a “individual.php” page. An example of he structure is follows:

    <body>

    <p class="title">

    London Bridge</p>

    <p class="caption">

    Image taken in summer 2009<br /><br /></p>

    <p class="image">

    <img border="0" class="floatleft" src="imagelink" width="250" height="400" />

    Low Shuttle Speed

    </p>

    </body>

How can i change this structure to suit my requirements?

Four. Can such “individual.php” url be renamed to something else with a unique id? Each image found in the database has their own unique ID.

Five. I have already queried the database in catalog.php. Can i somehow reuse this query individual.php?

In case you are wondering, getimage.php is as follows:

<?php

$id = $_GET['id'];
// do some validation here to ensure id is safe

$link = mysql_connect("localhost", "root", "");
mysql_select_db("photodb", $link);
$sql = "SELECT imagelink 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['imagelink']);

?>

Many thanks for reading my questions.

  • 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-26T07:11:01+00:00Added an answer on May 26, 2026 at 7:11 am

    Your last code snippet essentially answered your question – you’ll create another page and pass a variable to it through the URL ($_GET). So your URL may look like “individual.php?id=25” which would pull the image with the ID of ’25’. $_GET['id'] would be ’25’ in this example.

    I also noticed you are using the “root” user for the MySQL connection. I would strongly advise against that.

    http://www.1stwebdesigner.com/tutorials/getting-started-php-dynamic-content/

    http://www.greensql.com/articles/mysql-security-best-practices

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

Sidebar

Related Questions

I have an issue with dynamic, runtime controls. I create a group of controls
I have ran into an interesting issue while trying to create a more usable
We have an issue with an Outlook 2007 AddIn (created on a Windows 7
I have created a nested list with drag/drop functionality. My issue is that I
We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue on our page whereby the first time a button posts
I have a List object, with nested Tasks. I have created a page that
I m new to use ankhSVN and having issues. I have created some new
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager

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.