harrisonjf
asked on
Need PHP - MySQL Coding Assistance
I think I know conceptually what I want to do, but I lack the technical coding skills to get it right. Any help/guidance will be sincerely appreciated.
I am working with a simple MySQL membership database - one record for each member.
I also have a set member photos (mugshots) stored as jpg images in a folder on the server.
I would like to store a path to each member's photo in the MySQL database record for that member and then, use PHP code, to grab that photo and display it as part of the member's "Profile".
So...
What is the proper way to store an image path in a MySQL field?
What PHP code do I need to grab & display the member's photo record?
Unfortunately, my MySQL & PHP coding & syntax skills are petty lame, so any specific code examples would me much appreciated.
Thanks!
I am working with a simple MySQL membership database - one record for each member.
I also have a set member photos (mugshots) stored as jpg images in a folder on the server.
I would like to store a path to each member's photo in the MySQL database record for that member and then, use PHP code, to grab that photo and display it as part of the member's "Profile".
So...
What is the proper way to store an image path in a MySQL field?
What PHP code do I need to grab & display the member's photo record?
Unfortunately, my MySQL & PHP coding & syntax skills are petty lame, so any specific code examples would me much appreciated.
Thanks!
Images are converted to binary and then save in a column of type BLOB. To show the image you get the binary code and convert it back.
I have linked to a fairly good tutorial that you should be able to use to get all the code you need. Some bits of it you can probably skip.
http://www.phpriot.com/articles/images-in-mysql
I have linked to a fairly good tutorial that you should be able to use to get all the code you need. Some bits of it you can probably skip.
http://www.phpriot.com/articles/images-in-mysql
ASKER
Hi Folks,
Thank you so much for your responses to my inquiry -- however, I'd prefer not to store the images themselves in the MySQL database -- just some sore of link or reference to them and their location on the server.
Also, while I'm sure that the direct MySQL code could work -- I am modifying an existing PHP script that already displays each club member's profile data -- so I would prefer a more direct PHP code based solution to display an image, if possible.
(I do realize that PHP can execute MySQL code, if done correctly. It's the "done correctly" part that becomes the issue for me)
Thanks,
---Jared harrison
Thank you so much for your responses to my inquiry -- however, I'd prefer not to store the images themselves in the MySQL database -- just some sore of link or reference to them and their location on the server.
Also, while I'm sure that the direct MySQL code could work -- I am modifying an existing PHP script that already displays each club member's profile data -- so I would prefer a more direct PHP code based solution to display an image, if possible.
(I do realize that PHP can execute MySQL code, if done correctly. It's the "done correctly" part that becomes the issue for me)
Thanks,
---Jared harrison
Then post some code how / where you want to integrate it.
It would help if you could also paste up a table structure for the member data. If it is an existing system then it probably has the image columns already defined.
ASKER
Thank you for the additional suggestions. I will try to be much more specific in my request.
As an example, a record in the MySQL table has the filename of the photo (jared_harrison.jpg) stored in a text field called "Photo".
The PHP code I am trying to modify to display the actual photo, instead of the filename of the photo, currently looks like this:
55 <tr>
56 <th class="WADADataTableHeader ">Photo</t h>
57 <td class="WADADataTableCell"> <?php echo($row_WADAsitelok['Cus tom10']); ?></td>
58 </tr>
59 </table>
So I am trying to use the $row... data in the above table cell to display the actual photo (vs. the filename) with code similar to this:
<?php
echo '<img src="../members/photos/jar ed_harriso n.jpg"/>';
?>
While this seems like it shouldn't be too difficult, I can't seem to get the code and/or syntax right. I get parsing errors no matter how I construct the phrase -- probably, because I am only guessing at the code, as opposed to knowing how to properly construct the PHP statement.
---Jared Harrison
As an example, a record in the MySQL table has the filename of the photo (jared_harrison.jpg) stored in a text field called "Photo".
The PHP code I am trying to modify to display the actual photo, instead of the filename of the photo, currently looks like this:
55 <tr>
56 <th class="WADADataTableHeader
57 <td class="WADADataTableCell">
58 </tr>
59 </table>
So I am trying to use the $row... data in the above table cell to display the actual photo (vs. the filename) with code similar to this:
<?php
echo '<img src="../members/photos/jar
?>
While this seems like it shouldn't be too difficult, I can't seem to get the code and/or syntax right. I get parsing errors no matter how I construct the phrase -- probably, because I am only guessing at the code, as opposed to knowing how to properly construct the PHP statement.
---Jared Harrison
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simple, direct... and it WORKS!
Thanks!
Thanks!
You're welcome. Thanks for the points.
I would just save the image name in the db if the images are stored in the same folder. You could pull the image name with mysql
Open in new window
I just typed it without checking...but you get the idea