flagermus Posted November 22, 2008 Share Posted November 22, 2008 I have this site where I have inserted pictures from a database. Now I want these pictures to link to another search in the database (it should go to more information about this pictures). Do I really have to create a new page for each search? Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/ Share on other sites More sharing options...
genericnumber1 Posted November 22, 2008 Share Posted November 22, 2008 ignoring that storing images in a database.... no you don't You can use an "image" page that generates a specific image based upon the query string. Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696466 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 In the databese I only have the url to the pictures But how do I make an image page? Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696470 Share on other sites More sharing options...
cooldude832 Posted November 22, 2008 Share Posted November 22, 2008 file_get_contents and then imagecreatefromstring Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696477 Share on other sites More sharing options...
genericnumber1 Posted November 22, 2008 Share Posted November 22, 2008 If you have a url to the picture, just use an img tag with the location set to the image's url. running file_get_contents() on a huge file is an expensive operation. Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696491 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 Okay, I show some of the code here. I think I have already made an image tag like you sad? <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> <? $output[] = "<h1>Movies</h1>"; $sql = "select * from movies where Produkt='movie'"; $result = $db->query($sql); while ($row = $result->fetch()) { $output[] = "<a href='$row[billedeElFilm]' target='_blank'><img src='$row[billedeElFilm]' width='150' height='100' border='10' /></a>"; } $output[] = "<h1>Brochurer</h1>"; $sql = "select * from movies where Produkt='brochure'"; $result = $db->query($sql); while ($row = $result->fetch()) { $output[] = "<a href='$row[billedeElFilm]' target='_blank'><img src='$row[billedeElFilm]' width='150' height='100' border='10' /></a>"; } echo join('',$output); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696504 Share on other sites More sharing options...
DeanWhitehouse Posted November 22, 2008 Share Posted November 22, 2008 Try something like <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> <?php $output[] = "<h1>Movies</h1>"; $sql = "select * from movies where Produkt='movie'"; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { $output[] = "<a href='".$row['BilledeElFilm']."' target='_blank'><img src='".$row['BilledeElFilm']."' width='150' height='100' border='10' /></a>"; } $output[] = "<h1>Brochurer</h1>"; $sql = "select * from movies where Produkt='brochure'"; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { $output[] = "<a href='".$row['BilledeElFilm']."' target='_blank'><img src='".$row['BilledeElFilm']."' width='150' height='100' border='10' /></a>"; } foreach($output as $out) { echo $out; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696515 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 Try something like <body bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> <?php $output[] = "<h1>Movies</h1>"; $sql = "select * from movies where Produkt='movie'"; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { $output[] = "<a href='".$row['BilledeElFilm']."' target='_blank'><img src='".$row['BilledeElFilm']."' width='150' height='100' border='10' /></a>"; } $output[] = "<h1>Brochurer</h1>"; $sql = "select * from movies where Produkt='brochure'"; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { $output[] = "<a href='".$row['BilledeElFilm']."' target='_blank'><img src='".$row['BilledeElFilm']."' width='150' height='100' border='10' /></a>"; } foreach($output as $out) { echo $out; } ?> </body> </html> The "$row['BilledeElFilm']" is just the pictures and when you click you will get it in big. What I want is when you click on the picture you get a "new page" where you only have this one picture and the rest of the informations from the tabel. I don't think that's what you have explained here? Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696526 Share on other sites More sharing options...
DeanWhitehouse Posted November 22, 2008 Share Posted November 22, 2008 I fixed your code that was all. Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696528 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 ahh okay, thank you The code already works as it is, but I will change it, if that's better Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696529 Share on other sites More sharing options...
GingerRobot Posted November 22, 2008 Share Posted November 22, 2008 You need to pass something to identify the particular image to a new page. If, as i would hope, you have a unique ID in your database table, then you might generate links like: http://www.yoursite.com/viewimage.php?pic_id=323; You would then do something like this in viewimage.php: <?php $pic_id = (int) $_GET['pic_id'];//int cast to prevent SQL injection $sql = "SELECT * FROM yourtable WHERE id=$pic_id"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $row = mysql_fetch_assoc($result); //print out information - a caption for example echo 'Caption: '.$row['caption']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696530 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 You need to pass something to identify the particular image to a new page. If, as i would hope, you have a unique ID in your database table, then you might generate links like: http://www.yoursite.com/viewimage.php?pic_id=323; You would then do something like this in viewimage.php: <?php $pic_id = (int) $_GET['pic_id'];//int cast to prevent SQL injection $sql = "SELECT * FROM yourtable WHERE id=$pic_id"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $row = mysql_fetch_assoc($result); //print out information - a caption for example echo 'Caption: '.$row['caption']; ?> thank you very much! That works Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696552 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 But what can I write insted of the ID-number in the end of the url? Because there are more than one picture for every of this codes: $output[] = "<a href='$row[billedeElFilm]' target='_blank'><img src='$row[billedeElFilm]' width='150' height='100' border='10' /></a>"; Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696562 Share on other sites More sharing options...
flagermus Posted November 22, 2008 Author Share Posted November 22, 2008 of course it's just .row[iD]. !! Quote Link to comment https://forums.phpfreaks.com/topic/133823-is-this-possibly/#findComment-696563 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.