Jarel101 Posted April 30, 2011 Report Share Posted April 30, 2011 I'm trying to create something exactly like this: http://hypebeast.com/page/2/ I have some images on photobucket that I want to link to my mysql so I can display them dynamically on a web page...How is this done. I've heard I should store the image link in a blob field, but I've tried and it didn't allow me to right click and paste the link. I'm a beginner in php/mysql and any help would be greatly appreciated, thanks in advance. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted April 30, 2011 Report Share Posted April 30, 2011 Just thought I'd point this out... the link that you posted is using Wordpress (http://wordpress.org/) for the blog functionality. To answer your specific question, there are usually two ways to do this: -- store the image itself in a "blob" field. In general, I'd probably suggest avoiding this, since it could lead to large database sizes quickly. -- store the link to the image in a regular varchar or text field. This is how I suggest you would handle this. You can store the link to the file in the database, retrieve the link by querying the database, and then use PHP to display the image: <?php echo '<img src="' . $link_to_img . "' alt='' />"; ?> Quote Link to comment Share on other sites More sharing options...
Jarel101 Posted May 1, 2011 Author Report Share Posted May 1, 2011 I didn't realize that site was wordpress, A more accurate example of what I'm trying to create is this: Please forgive me but I'm a super newbie at all of this, I don't understand how to use the <?php echo '<img src="' . $link_to_img . "' alt='' />"; ?> code, can you explain. How do I retrieve the link by querying the database? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted May 1, 2011 Report Share Posted May 1, 2011 Assuming the link to the image file is stored in the database, you would need to use a select query to get it. See http://www.tizag.com/mysqlTutorial/mysqlselect.php for more info. This code: <?php echo '<img src="' . $link_to_img . "' alt='' />"; ?> Simply displays an image on the page. The "echo" displays something to the page, and you are telling PHP to display an image (note the "<img" tag) with the src of the image (the path to the image) set to a $link_to_img variable (which should contain the link to the image that you retrieved from the database.) If all of this sounds very confusing, you may want to take a step back and pick up at least some PHP basics before you continue. I'd suggest taking a look at some of the beginning PHP videos here: http://killerphp.com/tutorials/beginners-php/ and here: http://phpvideotutorials.com/free You might also want to watch the "insert" video, which covers some information about the MySQL insert query: http://killerphp.com/mysql/basic-sql-tutorial.php. Quote Link to comment Share on other sites More sharing options...
Guest elenalee Posted July 25, 2011 Report Share Posted July 25, 2011 Please inform me how to insert images from SQl Quote Link to comment Share on other sites More sharing options...
falkencreative Posted July 25, 2011 Report Share Posted July 25, 2011 Please inform me how to insert images from SQl The comments above basically explains how to do it. In most cases, you sill store the path to the image file in the database, and use PHP/MySQL to query the database and display the image with that path. Quote Link to comment Share on other sites More sharing options...
Guest AYOBRA Posted August 12, 2011 Report Share Posted August 12, 2011 guys i would rely like you to help me with the codes for saving and displaying images in php and mysql 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.
Note: Your post will require moderator approval before it will be visible.