Help with PHP pictures in mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gord1020
Forum Newbie
Posts: 7
Joined: Tue Apr 21, 2009 8:10 pm

Help with PHP pictures in mysql

Post by gord1020 »

Hey all,

OKay so I finally have my search function working using PHP and mysql!! take a look here: http://stevenspraguememorialrun.com/search.php JUST TYPE "31" in the bib field. As you can see after you type 31 you get a page with all the results for that Bib as well as a picture with the person in it. I achieved this by adding another column to my mysql table called "image" then typed in "<img src="/racepics/DSC_0014.jpg" into that specific row.

It works beautifully, the problem is I need to do this with over 300 people!! I cannot sit there and manually enter each image file name into the correct participants data field.

Does anyone have any suggestions? I did take the liberty of tagging each photo's metadata with the appropriate bib number.

Also something to note: some participants are in more than one photo. I don't know if that would change anything.

Thank you so much!!!
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: Help with PHP pictures in mysql

Post by anand »

Try doing this. In the table images, just keep the links. like "http://www.xyz.com/abc.jpg". By this, all users will have their own image slot. Just ask them to update their image links in that cell.

Now, in html, do this...

Code: Select all

 
<?php
$image = mysql_query("SELECT images FROM table_name WHERE bib='31' LIMIT 1;");
?>
 
<html>
<img src="<?=$image ?>">
 </html>
.
 
Hope this will help you
gord1020
Forum Newbie
Posts: 7
Joined: Tue Apr 21, 2009 8:10 pm

Re: Help with PHP pictures in mysql

Post by gord1020 »

I'm afraid I don't understand what you're describing. Won't I still somehow have to go through and copy and paste each and every image file name into the sql table?

Sorry,
Thank you!!!
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: Help with PHP pictures in mysql

Post by anand »

gord1020 wrote:I'm afraid I don't understand what you're describing. Won't I still somehow have to go through and copy and paste each and every image file name into the sql table?

Sorry,
Thank you!!!
Not really. You can let your users do that.

Can you again please explain what you want to say. Means, what you want to do.
gord1020
Forum Newbie
Posts: 7
Joined: Tue Apr 21, 2009 8:10 pm

Re: Help with PHP pictures in mysql

Post by gord1020 »

i have a search function that i want to make display pictures of a specific race participant. Basically I have pictures that are tagged with numbers (in their metadata), and I need to be able search these pictures.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Help with PHP pictures in mysql

Post by pickle »

Have a separate table that matches up an image to a user. There could be multiple entries for a given image, and multiple entries for a given user. You'll have to modify your search to search this other table.

Storing the information in metadata might be neat, but won't really be practical for this application, as you don't want to have to open the meta data of each image, when there's going to be so many. Find a way to convert that meta data into the image => user matchup.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply