Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with displaying image links stored in mysql


Isiah

Recommended Posts

Posted

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 ();

}

?>

Posted

not studied your code, but remember the dbase only contains the image file name, the image is stored in a dir on your server, so you must include the path to that to display.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Archived

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

×
×
  • Create New...