0

I've been working on these codes for 2 hours now and i can't seem to make it appear. It has the right ID, but the picture doesnt show. i have no idea why.

anyway, here are my codes.

this is for showing the pic along with other stuff.

<div align="left">
<center><img src="img/compressportbanner.jpg" height="180"></center>
    <table border="0" cellpadding="2px" width="600px">
        <?php

            $result=mysql_query("select * from inventory WHERE prod_brand = 'Compressport' AND prod_category='compression' ");
            while($row=mysql_fetch_array($result)){
        ?>
        <tr>
            <td>    

            <?php 
            echo '<'.'img src="image.php?prod_id='.$row['prod_id'].'" alt="'.$row['prod_name'].'" width="250">'; 

            ?> 
            </td>
            <td>    <b><?php echo $row['prod_name']?></b><br />
                    <?php echo $row['prod_category']?>
                    <!--<?php echo $row['prod_desc']?>-->
                    <br>
                    Price:<big style="color:green">
                        ₱ <?php echo $row['prod_price']?></big><br /><br />
                    <input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['prod_id']?>)" />

            </td>
        </tr>
        <tr><td colspan="2"><hr size="1" /></td>
        <?php } ?>
    </table>
</div>

and here is the image.php

<?php
$prodID=($_GET['prod_id']);
$sql = "SELECT * FROM `inventory` where `prod_id` = ".$prodID;
$qry = mysql_query($sql);
$result=mysql_fetch_array($qry);

echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['prod_pic'] ).'"/>'


?>

How do i make it appear, im new to php and im just starting to understand it.

geds13
  • 181
  • 2
  • 5
  • 21
  • http://stackoverflow.com/questions/13225726/i-need-my-php-page-to-show-my-blob-image-from-mysql-database – Zentoaku Aug 10 '14 at 18:22
  • possible duplicate of [displaying an image stored in a mysql blob](http://stackoverflow.com/questions/5525830/displaying-an-image-stored-in-a-mysql-blob) – IROEGBU Aug 11 '14 at 15:57

1 Answers1

0

Here's what I did with your codes, i added this line of code.

<?php echo '<img src="data:image/jpeg;base64,'.base64_encode($row['prod_pic']).'" width="250">';?> 

Here are the full codes.

<div align="left">
<center><img src="img/compressportbanner.jpg" height="180"></center>
    <table border="0" cellpadding="2px" width="600px">
        <?php

            $result=mysql_query("select * from inventory WHERE prod_brand = 'Compressport' AND prod_category='compression' ");
            while($row=mysql_fetch_array($result)){
        ?>
        <tr>
            <td>    

            <?php 

            echo '<img src="data:image/jpeg;base64,'.base64_encode($row['prod_pic']).'" width="250">';

            ?> 
            </td>
            <td>    <b><?php echo $row['prod_name']?></b><br />
                    <?php echo $row['prod_category']?>
                    <!--<?php echo $row['prod_desc']?>-->
                    <br>
                    Price:<big style="color:green">
                        ₱ <?php echo $row['prod_price']?></big><br /><br />
                    <input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['prod_id']?>)" />

            </td>
        </tr>
        <tr><td colspan="2"><hr size="1" /></td>
        <?php } ?>
    </table>
</div>
NewbieCoder999
  • 49
  • 4
  • 11