czappa Posted April 1, 2009 Share Posted April 1, 2009 I need help figuring this out. I am displaying results from competitions on my website. The user click the competition and then the results get pulled into a table. With in that table i would like to set a column to a picture of the athlete. I have the database set up to store the path to the file rather than the actual picture. i am unsure of how to reference the path being returned via the SQL statement. The path to the pictures would be ../08-09teamphotos/picname.jpg the actual website to see what i am doing is www.enaparamus.com/usaggirls/results.php mysql_select_db($database_online, $online); if(!isset($_GET['meetid'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT meetid, meetname FROM meet ORDER BY meetid"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $meethost = '<ol>'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($meetid, $meetname) = $row; $meethost .= "<li><a href=\"$self?meetid=$meetid\">$meetname</a></li>\r\n"; } $meethost .= '</ol>'; $meetname = 'Meet List'; } else { $query = "SELECT gymnasts.firstname, gymnasts.lastname, gymnasts.picref, meet.meethost, meet.meetname, meet.meetdate, meetresults.level, meetresults.vault, meetresults.vaulplace, meetresults.unevenbars, meetresults.unevenbarsplace, meetresults.beam, meetresults.beamplace, meetresults.floor, meetresults.floorplace, meetresults.aaplace, meetresults.vault+meetresults.unevenbars+meetresults.beam+meetresults.floor AS AATotal, meetresults.agegroup, meetresults.ID, meet.meetid FROM meet INNER JOIN (gymnasts INNER JOIN meetresults ON gymnasts.gymnastid = meetresults.gymnastid) ON meet.meetid = meetresults.meetid WHERE meet.meetid=".$_GET['meetid'] . " ORDER BY meetresults.`level`, AATotal DESC"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totalRows = mysql_num_rows($result); $meetname = $row['meetname']; $meethost = $row['meethost']; $firstname = $row['firstname']; $meetdate = $row['meetdate']; $v="Vault"; $ub="Bars"; $bb="Beam"; $fx="Floor"; $aa="All Around"; $Place="PL"; $Name="name"; $level="Level"; $AG="Age Goup"; $space =" "; } ?> <?php echo $meetname; ?></h1> <table align ="center" border =".5" class="resultstable" > <tr> <td > <h1 align="center"><?php echo $meetname; ?></h1> <?php echo $meethost; echo $space; echo $meetdate; ///echo $firstname; if(isset($_GET['meetid'])) { ?> <tr> <td colspan="2"><?php echo $name; ?>Name</td> <td> </td> <td><?php echo $level; ?></td> <td>Age Group</td> <td>Vault</td> <td>PL</td> <td>Bars</td> <td>PL</td> <td>Beam</td> <td>PL</td> <td>Floor</td> <td>PL</td> <td>AA</td> <td>PL</td> </tr> <?php do { ?> <tr> <td colspan="2"><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><?php echo $row['level']; ?></td> <td><?php echo $row['agegroup']; ?></td> <td><?php echo $row['vault']; ?></td> <td><?php echo $row['vaulplace']; ?></td> <td><?php echo $row['unevenbars']; ?></td> <td><?php echo $row['unevenbarsplace']; ?></td> <td><?php echo $row['beam']; ?></td> <td><?php echo $row['beamplace']; ?></td> <td><?php echo $row['floor']; ?></td> <td><?php echo $row['floorplace']; ?></td> <td><?php echo $row['AATotal']; ?></td> <td><?php echo $row['aaplace']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> <p> </p> <p align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Meet List</a></p> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/ Share on other sites More sharing options...
cunoodle2 Posted April 1, 2009 Share Posted April 1, 2009 I would recommend only storing the path to the image as apposed to the actual image itself. Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798369 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 I am only storing the path in the db. Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798505 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 I need help figuring this out. I am displaying results from competitions on my website. The user click the competition and then the results get pulled into a table. With in that table i would like to set a column to a picture of the athlete. I have the database set up to store the path to the file rather than the actual picture. i am unsure of how to reference the path being returned via the SQL statement. The path to the pictures would be ../08-09teamphotos/picname.jpg the actual website to see what i am doing is www.enaparamus.com/usaggirls/results.php mysql_select_db($database_online, $online); if(!isset($_GET['meetid'])) { $self = $_SERVER['PHP_SELF']; $query = "SELECT meetid, meetname FROM meet ORDER BY meetid"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $meethost = '<ol>'; while($row = mysql_fetch_array($result, MYSQL_NUM)) { list($meetid, $meetname) = $row; $meethost .= "<li><a href=\"$self?meetid=$meetid\">$meetname</a></li>\r\n"; } $meethost .= '</ol>'; $meetname = 'Meet List'; } else { $query = "SELECT gymnasts.firstname, gymnasts.lastname, gymnasts.picref, meet.meethost, meet.meetname, meet.meetdate, meetresults.level, meetresults.vault, meetresults.vaulplace, meetresults.unevenbars, meetresults.unevenbarsplace, meetresults.beam, meetresults.beamplace, meetresults.floor, meetresults.floorplace, meetresults.aaplace, meetresults.vault+meetresults.unevenbars+meetresults.beam+meetresults.floor AS AATotal, meetresults.agegroup, meetresults.ID, meet.meetid FROM meet INNER JOIN (gymnasts INNER JOIN meetresults ON gymnasts.gymnastid = meetresults.gymnastid) ON meet.meetid = meetresults.meetid WHERE meet.meetid=".$_GET['meetid'] . " ORDER BY meetresults.`level`, AATotal DESC"; $result = mysql_query($query) or die('Error : ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totalRows = mysql_num_rows($result); $meetname = $row['meetname']; $meethost = $row['meethost']; $firstname = $row['firstname']; $meetdate = $row['meetdate']; $v="Vault"; $ub="Bars"; $bb="Beam"; $fx="Floor"; $aa="All Around"; $Place="PL"; $Name="name"; $level="Level"; $AG="Age Goup"; $space =" "; } ?> <?php echo $meetname; ?></h1> <table align ="center" border =".5" class="resultstable" > <tr> <td > <h1 align="center"><?php echo $meetname; ?></h1> <?php echo $meethost; echo $space; echo $meetdate; ///echo $firstname; if(isset($_GET['meetid'])) { ?> <tr> <td colspan="2"><?php echo $name; ?>Name</td> <td> </td> <td><?php echo $level; ?></td> <td>Age Group</td> <td>Vault</td> <td>PL</td> <td>Bars</td> <td>PL</td> <td>Beam</td> <td>PL</td> <td>Floor</td> <td>PL</td> <td>AA</td> <td>PL</td> </tr> <?php do { ?> <tr> <td colspan="2"><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><?php echo $row['level']; ?></td> <td><?php echo $row['agegroup']; ?></td> <td><?php echo $row['vault']; ?></td> <td><?php echo $row['vaulplace']; ?></td> <td><?php echo $row['unevenbars']; ?></td> <td><?php echo $row['unevenbarsplace']; ?></td> <td><?php echo $row['beam']; ?></td> <td><?php echo $row['beamplace']; ?></td> <td><?php echo $row['floor']; ?></td> <td><?php echo $row['floorplace']; ?></td> <td><?php echo $row['AATotal']; ?></td> <td><?php echo $row['aaplace']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> <p> </p> <p align="center"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Meet List</a></p> <?php } ?> Which field is the picture path stored in? Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798508 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 the path is stored in gymnasts.picref i just cant figure out how to display the picture, i can display the path when put the field into the result table. what is the syntax to display the image itself. Thanks! Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798511 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 the path is stored in gymnasts.picref i just cant figure out how to display the picture, i can display the path when put the field into the result table. what is the syntax to display the image itself. Thanks! ////ok say you want to display an image with the filename of "big_head_guy.jpg" <td><img src="http://<? echo $_SERVER['HTTP_HOST'].'/path_to/image/folder/'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td> ///was that what you were looking for? ///Or is the image in a folder not accessible from the web server?? ///which in this case you would do this <? //ABSOLUTE PATH... ///linux /home/username/path/to/image/folder... //windows C:\my web folder \............. $path = 'Absolute_path_to/image/folder/'.$row['picref']; $image = file_get_contents($path); ?> <td><? echo $image;?></td> well something like that Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798537 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 the path to the image is what i have stored in the DB the filed 'picref' is the path to the file. what i am looking for is a way to display the image when the path is called using the field 'picref' thanks Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798548 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 the path to the image is what i have stored in the DB the filed 'picref' is the path to the file. what i am looking for is a way to display the image when the path is called using the field 'picref' thanks could you send me a sample row from the DB also i want to see what the path that's coming from the Database looks like Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798556 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 check www.enateam.com/usag/results.php that is my testing site. are you looking for the image path? image path is ../08-09teamphotos/ that is relative to the location of results.php <?php echo $meethost; echo $space; echo $meetdate; ///echo $firstname; // when displaying meet list show a link // to see the results if(isset($_GET['meetid'])) { ?> <tr> <td colspan="2"><?php echo $name; ?>Name</td> <td> </td> <td> </td> <td><?php echo $level; ?></td> <td>Age Group</td> <td>Vault</td> <td>PL</td> <td>Bars</td> <td>PL</td> <td>Beam</td> <td>PL</td> <td>Floor</td> <td>PL</td> <td>AA</td> <td>PL</td> </tr> <?php do { ?> <tr> <td colspan="2"><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><img src="http://<? echo $_SERVER['HTTP_HOST'].'../08-09teamphotos'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td> <td><?php echo $row['level']; ?></td> <td><?php echo $row['agegroup']; ?></td> <td><?php echo $row['vault']; ?></td> <td><?php echo $row['vaulplace']; ?></td> <td><?php echo $row['unevenbars']; ?></td> <td><?php echo $row['unevenbarsplace']; ?></td> <td><?php echo $row['beam']; ?></td> <td><?php echo $row['beamplace']; ?></td> <td><?php echo $row['floor']; ?></td> <td><?php echo $row['floorplace']; ?></td> <td><?php echo $row['AATotal']; ?></td> <td><?php echo $row['aaplace']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798574 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 check www.enateam.com/usag/results.php that is my testing site. are you looking for the image path? image path is ../08-09teamphotos/ that is relative to the location of results.php <?php echo $meethost; echo $space; echo $meetdate; ///echo $firstname; // when displaying meet list show a link // to see the results if(isset($_GET['meetid'])) { ?> <tr> <td colspan="2"><?php echo $name; ?>Name</td> <td> </td> <td> </td> <td><?php echo $level; ?></td> <td>Age Group</td> <td>Vault</td> <td>PL</td> <td>Bars</td> <td>PL</td> <td>Beam</td> <td>PL</td> <td>Floor</td> <td>PL</td> <td>AA</td> <td>PL</td> </tr> <?php do { ?> <tr> <td colspan="2"><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><img src="http://<? echo $_SERVER['HTTP_HOST'].'../08-09teamphotos'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td> <td><?php echo $row['level']; ?></td> <td><?php echo $row['agegroup']; ?></td> <td><?php echo $row['vault']; ?></td> <td><?php echo $row['vaulplace']; ?></td> <td><?php echo $row['unevenbars']; ?></td> <td><?php echo $row['unevenbarsplace']; ?></td> <td><?php echo $row['beam']; ?></td> <td><?php echo $row['beamplace']; ?></td> <td><?php echo $row['floor']; ?></td> <td><?php echo $row['floorplace']; ?></td> <td><?php echo $row['AATotal']; ?></td> <td><?php echo $row['aaplace']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> Change <td><img src="http://<? echo $_SERVER['HTTP_HOST'].'../08-09teamphotos'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td> To <td><img src="http://<? echo $_SERVER['HTTP_HOST'].'/usag/08-09teamphotos/'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td> the $_SERVER['HTTP_HOST'] is an equal to www.enateam.com we use it so when the site is moved we don't have to change the links also i checked the source and i didn't see the <td> that suppose to have the IMG tag can you tell me where it's suppose to be? Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798614 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 the code is <tr> <td colspan="2"><?php echo $row['firstname']; ?></td> <td><?php echo $row['lastname']; ?></td> [color=red][b]<td><img src="http://<? echo $_SERVER['www.enaparamus.com'].'/08-09teamphotos/'.$row['picref']; ?>" alt="<?=$row['image_name']?>"></td>[/b][/color] <td><?php echo $row['level']; ?></td> <td><?php echo $row['agegroup']; ?></td> <td><?php echo $row['vault']; ?></td> <td><?php echo $row['vaulplace']; ?></td> <td><?php echo $row['unevenbars']; ?></td> <td><?php echo $row['unevenbarsplace']; ?></td> <td><?php echo $row['beam']; ?></td> <td><?php echo $row['beamplace']; ?></td> <td><?php echo $row['floor']; ?></td> <td><?php echo $row['floorplace']; ?></td> <td><?php echo $row['AATotal']; ?></td> When i view the results i get a representation of an image but the path is wrong now. i am storing only the file name in the field Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798657 Share on other sites More sharing options...
czappa Posted April 1, 2009 Author Share Posted April 1, 2009 ok i got it to work, there was an error in my SQL statement. Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798668 Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 ok i got it to work, there was an error in my SQL statement. beautiful i am happy for you one more thing This is wrong <? echo $_SERVER['www.enaparamus.com'].'/08-09teamphotos/'.$row['picref']; ?> This is right <? echo $_SERVER['HTTP_SERVER'].'/08-09teamphotos/'.$row['picref']; ?> good luck with your project Link to comment https://forums.phpfreaks.com/topic/152015-solved-question-displaying-image-from-path-stored-indb/#findComment-798696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.