simcoweb Posted September 14, 2006 Share Posted September 14, 2006 I'm at a complete standstill with finishing a project where I have to display an image of each person that's a member of a modest sized organization (about 25 people). I have the pictures uploading fine to the proper directory on the server. I even have the file name inserted into the Mysql database.What I can't figure out is HOW to call the proper image for the right person. The image file name is in the same table row as the other information about the person (name, username, phone, etc.) Perhaps I should have a separate table for the images with an image_id field that is auto-incremented and connect the person to the image_id? I'm looking for some help here on where to go from here. The page i'm putting this into is here:http://www.plateauprofessionals.com/display.phpThis is driving me NUTS as i've spent literally 5 days researching and testing. Help? Quote Link to comment Share on other sites More sharing options...
PigsHidePies Posted September 14, 2006 Share Posted September 14, 2006 lol great profile page...i cant really help ya...more out of fear from alonzo than anything else..good luck dude Quote Link to comment Share on other sites More sharing options...
Zane Posted September 14, 2006 Share Posted September 14, 2006 please don't name you're topics with something like HELP ME...titles are meant to give people an idea of what's insideIf you would could you come up with a decent title..you will get more help that way toand don't start a new topic....and as for you're question...you'll have to use URL variables AKA GET varslikedisplay?id=89would pull up the profile info for profile id #89 with an SQL statement Quote Link to comment Share on other sites More sharing options...
jwwceo Posted September 14, 2006 Share Posted September 14, 2006 When you link to the individual persons page embed their emplyee_id.so the page looks like thiswww.url.com?employee_id=3.Then, on the idividual persons page. Use something like$employee = $_GET['employees_id'];Yow have their employee id as an variable. Run a query in MySQl forWHERE employee_id = $employee and you will have everything from that row for use in the table.that's a basic overview.... Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 I changed the title. Sorry for being a little wild with that one. Ok, I understand what you're saying. I need to generate some type of 'id' flag to call the images that correspond to the proper profile.Question is... how? I've searched until my eyeballs have bugged out of my skull. Most of the info is about calling up pics into a gallery or displaying all the pics in a folder. Basically here's what i've got:user registers and registration form includes photo uploaduser can log in to change their information if they wishphoto gets uploaded to /images/photo folderMy 'display.php' page pulls each person's profile into the page and displays it in some semi-fancy html output. I've gotten all the detail stuff to show. What I can't figure out is how to set up the image system so that they will show.So.. some guidance/examples/tutorials/code snippets would be MUCH appreciated. Thanks! Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 jwwceo, thanks for that suggestion. I have thought of that as well. That would involve having some type of 'listing' or 'summary' page where visitor sees a category, clicks on it, then that displays a short blurb about each person with a link to their profile which would then show everything. That would allow me to use your method which might be the better way to go. I had no idea this was so complicated. I was assuming I could just use an echo statement that included the image path and a variable set to call the image. But that ain't workin.Any further guidance you can provide? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 14, 2006 Share Posted September 14, 2006 [quote]What I can't figure out is HOW to call the proper image for the right person. The image file name is in the same table row as the other information about the person (name, username, phone, etc.)[/quote]So when you retrieve the row for a specific person you can retrieve the image file name, right? And then you can use something simple like:[code]echo "<img src='". $row['image_file_name']. "'>"; // if database contains full file name & path[/code]or maybe it's:[code]echo "img src='images/photo/". $row['image_file_name']. "'>";[/code] Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 AndyB, i've tried about 97 variations of that type of call. The database does NOT contain the file path. Only the file name (like '4202842.jpg' for example)I've inserted your suggestion and get this error when doing so:[code]Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home2/wwwplat/public_html/display.php on line 51[/code]Line 51 is this:[code]<td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='229' valign='top'><? echo "<img src='images/photo/". $row['imageFile']. "'>"; ?></td>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 14, 2006 Share Posted September 14, 2006 There's no error on line 51. The php interpreter has finally 'broken' on line 51 because an earlier line has a mismatched ', " or something. Post lines 40-51 and we'll spot it. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Here's line 40 and up to 51:[quote]while ($row = mysql_fetch_assoc($result)) { extract($row); echo <<<HTML<div align='center'><table border='0' cellpadding='0' style='border-collapse: collapse' width='530'><tr><td colspan='2' background='http://www.plateauprofessionals.com/images/top2.gif' width='530' height='35' style='padding: 10px'><h2>$name</h2></td></tr><tr><td height='15' colspan='2'></td></tr><tr>[/quote] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 14, 2006 Share Posted September 14, 2006 Oh, it's in the middle of a HEREDOC statement ... and I doubt we can start an echo in the middle of a chunk of stuff that's being echo'd starting from the <<<HTML. Try this for line 51:[code]<td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='229' valign='top'><img src='images/photo/$imageFile'></td>[/code] Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 GLORY BE TO GOD! THE IMAGES SHOW!Now...one more question. HOW can I make those resize to a set of global dimensions? I mean, aside from putting in some height/width parameters, i'd like to have these 'resized' to the proper dimensions so I can keep their clarity and manipulate the display of these images from page to page.I have this function code I snagged but not sure how i'd adapt it to my needs. Here it is:[code]$mysock = getimagesize("images/photo/image_name_here");// image resize functionfunction imageResize($width, $height, $target) {/*takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image*/if ($width > $height) {$percentage = ($target / $width);} else {$percentage = ($target / $height);}//gets the new value and applies the percentage, then rounds the value$width = round($width * $percentage);$height = round($height * $percentage);//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get thereturn "width=\"$width\" height=\"$height\"";}[/code]I would assume I could rename that '$mysock' variable and set the parameters to insert into the image src. Not sure. Guessing. Ideas? Quote Link to comment Share on other sites More sharing options...
Zane Posted September 14, 2006 Share Posted September 14, 2006 The way I'd do this is to have something like a constant width in mind...like all images will have such a widthand do some proportional math to the image's sizelike[code]$mysock = getimagesize("images/photo/image_name_here");$setWidth = 200;function imageResize($width, $height, $target) {$newHeight = 0;$newHeight = ($setWidth * $height) / $width;return "width='{$setWidth}' height='{$newHeight}'";}[/code] Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Thanks, Zanus. The only problem with having 'a' global size is that I may want the uploaded image to be displayed in 2 or 3 different sizes depending on the page being viewed. That way I can have just one image uploaded but have it viewed as a thumbnail, medium sized or full sized image.In that code snippet it makes a reference to 'a' particular image. I need something that would point to the $imageFile or field name of the image used/uploaded by each individual. Can that be done? Quote Link to comment Share on other sites More sharing options...
simcoweb Posted September 14, 2006 Author Share Posted September 14, 2006 Also, in the event that IF there's no pic uploaded for a person I want it to display a placeholder pic or text that says No Photo Available. A placeholder pic would be nicer. I'm not sure how to implement this but my simple-logic mind has something like this:$image = mysql_result($result2, 'imageFile');[code]if (!isset ($image)) { echo "No Photo Available";} [/code]Can someone point me in the right direction on having a substitute image to display? Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.