Jump to content



Recommended Posts

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.

Link to comment
Share on other sites

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='' />"; ?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...