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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:25:25+00:00 2026-06-04T00:25:25+00:00

I’m creating a photo tagging project using mysql and php, that not only just

  • 0

I’m creating a photo tagging project using mysql and php, that not only just adds tags to photos but it also returns related tags that I have stored in the my database. I am almost done my project (sort of), just stuck on the part where i have to return the related tags when i upload the photos.

My database is called tagger and i have two tables “image”(ImageId, Name, TagId) and “tag”(ID, Tag).

I have 3 php pages database.php, index.php (where i upload the image with tag), and show.php i have no problem uploading the images with tags but i also want to make it in way that returns related tags as well. For example if i uploaded a baby picture and added the tag “baby smile” when i upload it, it would write next to “baby smile child laugh”. i don’t know how to do that.

This is my code for show.php:

<?
require_once('/database.php');
$dbconnect = NEW DB_Class('tagger', 'root', '');
$query = "SELECT * FROM image, tag WHERE image.TagID = tag.ID";
$result = $dbconnect->fetch($query);
echo "<table border='2'>";
foreach ($result as $record) 
{ 
echo "<tr>";
echo "<td>";
echo "<a href='images/".$record['Name']."' target='_blank'>
<img src='images/".$record['Name']."' alt='SSsss' height='120' width='120' /></a>";
echo "</td>";
echo "<td>";
echo $record['Tag'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>

<form name="newad" method="post" enctype="multipart/form-data"  
action="">

<table align="center" >
<tr>
<td> <h2>Image to upload: </h2> </td>
<td><input type="file" name="image"></td>
</tr>
<tr>
<td><h2>Tags:</h2></td>
<td><input type="text" name="tags"/></td>
</tr>
<tr>
<td></td>

<td><input name="Submit" type="submit" value="Upload image" style="width 120px;       height: 70px;font-size:20px"></td>
</form>
</tr>
<br/>
</table>

</form>

Would i have to add like a whole new table called “synonyms” for example? I’m totally lost, any help would be much appreciated. If you guys need to see the codes for the other two pages, I’ll show those as well. Thanks.

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

    Your database schema looks like you can add only one tag for an image, but your using “tags” in your description. Lets asume this is your table schema Image: (ImageId, Name), and Tag(TagId, ImageId, Tag). Make the appropriate modifications if necessary.

    Now create the synonyms table as a cached table, that can be updated from as a cron job.

    SELECT rel.Tag as related_tag, tag.Tag as tag, COUNT(tag.Tag) as connections 
    FROM tags rel
    LEFT JOIN tags tag ON tag.ImageId = rel.ImageId
    GROUP BY tag.Tag
    WHERE COUNT(tag.Tag) > 5 -- Use $image_count/10 or 100 or other appropriate value
    

    And then insert rows into the cached tabled. If you don’t have a lot of images you can just call this query each time.

    So if your table looks like this

    1, 1, baby
    2, 2, car
    3, 1, smile
    4, 1, laugh
    5, 1, child
    6, 2, baby
    7, 2, child
    

    Your result will be:
    (tag, related_tag, connections)

    baby, smile, 1
    baby, laugh, 1
    baby, child, 2
    smile, baby, 1
    smile, laugh, 1
    ...
    

    This way you can create a table that shows which tags appear together in 5 images or more.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.