scuttzz Posted October 25, 2013 Share Posted October 25, 2013 Hi all, Need some guide line, im outputing images from a databse on a page, ive gotten to the point that the images show as i want them to however Im putting a link under each image. so my question is, is there a way to have a image link change depending on the image id, but that page that it points to is a separate page that is not connected to a database.The thought process is as follows: admin uploades the image => image shows in a page with a link =>User clicks the link and it directs them to a page(example www.mysite.com/image_information/image1.php) again the links p[age is completely seperate, the image has an id.Heres the code id have so farPHP: $uploadedImage = ""; $sql = mysql_query("SELECT * FROM products"); $imageCount = mysql_num_rows($sql); // count the output amount if ($imageCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= ' <div class="itemWrapper"> <a id="inventoryImage" href="product.php?id =' . $id .'"><img src="uploaded_images/' . $id . '.jpg"></a> <div id="imageInfo"> <ul border="1"> <li><span>Date Added : ' . $date_added . '</span></li> <li><a href="">Read more about this image</a></li> </ul> </div> <div class="clear"></div> </div> '; } } else { uploadedImage = "We have no images uploaded yet"; } Link to comment https://forums.phpfreaks.com/topic/283265-dynamically-changing-a-link-in-php-to-have-it-point-to-a-external-page/ Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 This line <a id="inventoryImage" href="product.php?id =' . $id .'"><img src="uploaded_images/' . $id . '.jpg"></a> Outputs the products image and the link to display the products information. Are you saying some products information are not stored in the database. Those that are not stored in the database have static html pages defined for them? Link to comment https://forums.phpfreaks.com/topic/283265-dynamically-changing-a-link-in-php-to-have-it-point-to-a-external-page/#findComment-1455355 Share on other sites More sharing options...
scuttzz Posted October 25, 2013 Author Share Posted October 25, 2013 Yes that's the jist of it.. The database has no information about the image in it, its just a table with 2 columns (id, image). I've created pages for each image that are not connected to the database itself. Do you think it would be a better option to add information to the database and not show it, and when the user chicks the link have the page change to the one with all the information instead? The reason why I'm going this route is the information about the image is rather long with jquery tabs involved. Link to comment https://forums.phpfreaks.com/topic/283265-dynamically-changing-a-link-in-php-to-have-it-point-to-a-external-page/#findComment-1455357 Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 You don't store the whole webpage in the database. Each product you add to the database should contain just the raw information about it. Such as product id image(s) name description price (if applicable) etc Then in product.php you grab all the information about that product. Once you have got all data about that product you use PHP to generate the page. Using the database to just store the product image and then coding static webpages for each product is not very efficient. Link to comment https://forums.phpfreaks.com/topic/283265-dynamically-changing-a-link-in-php-to-have-it-point-to-a-external-page/#findComment-1455362 Share on other sites More sharing options...
scuttzz Posted October 25, 2013 Author Share Posted October 25, 2013 Understandable, so ill only store information in the database, and call it where see fit. think im going to change my thoughts with this one, as getting a link to change depending on the image id and to make it link to a external page is a little out of my understanding at this point. Ill just store more information on the database and call it on the products.php? page. sorry for wasting your time. Link to comment https://forums.phpfreaks.com/topic/283265-dynamically-changing-a-link-in-php-to-have-it-point-to-a-external-page/#findComment-1455367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.