2 Replies Latest reply on Dec 14, 2015 7:40 AM by Rob Hecker2

    how to link image to mysql database using php?


      Hey i am making online shopping portal as my term project. I want to add an image for everything that is available in my database for sale, so that when user click on that image all delete about it are shown in a form. Kindly help me regarding this ASAP.

        • 1. Re: how to link image to mysql database using php?
          BenPleysier Adobe Community Professional & MVP

          This tutorial will give you an idea of what is required. Problem is that the tutorial makes use of PHP code that will not work in the latest version of PHP. MySQL has made way for MySQLi and PDO.

          • 2. Re: how to link image to mysql database using php?
            Rob Hecker2 Most Valuable Participant

            Store the image names in the record containing your item details. Do not store the actual image in the database. If all images are in the same location, you do not need to include the path.


            Database record example

            product_id (int autoincrement primary key)

            product_name (varchar 150)

            product_price (decimal 6,2)

            product_description (text)

            taxable (boolean)

            product_image (varchar 100)


            Then, after loading your recordset, the following line would provide a link to the product details, using the image as the link:


            <p><a href='productpage.php?product_id=<?php echo $product_id ?>'><img src='<?php echo "/images/$product_image ?>'></a> <?php echo "<b>$product_name</b><br/>[currency symbol goes here]$product_price<br/>$product_description " ?></p>


            . . .this gives you the idea. Change to suit your own variable names, etc.