Jump to content

Help with displaying image links stored in mysql


isiah

Recommended Posts

Ok so ive been getting better and learning more thanks to help of everyone. So im using oscommerce as my shopping cart and ive been searching web on why csv file i uploaded the products pictures werent showing up. I looked around and i found a few answers but remember im still new to this i found this code

but where would i place it. Would this code work to show the images stored in my database? Thanks to anyone who can help.

 

<?php

 

// Connect to database

 

$errmsg = "";

if (! @mysql_connect("localhost","trainee","abc123")) {

        $errmsg = "Cannot connect to database";

        }

@mysql_select_db("wellho");

 

// Find out about images to display

 

$limit = 3;

 

if ($_REQUEST[iwant]) {

        $whereclause = "where title like \"%".

                $_REQUEST[iwant].

                "%\"";

        $gotten = @mysql_query("select * from pix $whereclause order by pid desc limit $limit");

        while ($row = @mysql_fetch_assoc($gotten)) {

                $imcolumn .= "<tr><td><img src=?gim=$row[pid] width=144><br>";

                $imcolumn .= htmlspecialchars($row[title])."</td></tr>";

                $nim++;

        }

        if (! $nim) $imcolumn = "<tr><td>No matching images</td></tr>";

} else {

        $imcolumn .= "<tr><td>Images will appear here</td></tr>";

}

 

// If this is the image request, send out the image

 

if ($_REQUEST[gim]) {

        $gotten = @mysql_query("select * from pix where pid = $_REQUEST[gim]");

        $row = mysql_fetch_assoc($gotten);

        $bytes = $row[imgdata];

        header("Content-type: image/jpeg");

        print $bytes;

        exit ();

        }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.