You are here:  » show a set pf pictures only


show a set pf pictures only

Submitted by rolli1 on Wed, 2006-11-01 09:15 in

Hi David,
another beginner question ( sorry ).
If I have a database containing 500 pictures is it then possible to use PT as picture search and show featured pictures?

ROland

Submitted by support on Wed, 2006-11-01 10:37

Hi Roland,

That's a bit far from the functional specification of Price Tapestry to give an easy answer i'm afraid. In principle, you could borrow the database library code etc. from the distribution to do this; but it also depends on how your images are stored. There is not standard way to store images in a database - do you mean that the URLs are stored in the database rather than the image data?

Submitted by rolli1 on Wed, 2006-11-01 10:41

Hi David,

yes, I meant that the urls of the pics are stored.

ROland

Submitted by support on Wed, 2006-11-01 11:28

Taking the Price Tapestry products table as an example, which has an image_url field, you could do something like this to show 5 random images from the database:

<?php
  
require("includes/common.php");
  
$q sprintf("SELECT image_url FROM `".$config_databaseTablePrefix."products`ORDER BY RAND() LIMIT 5");
  if (
database_querySelect($q,$rows))
  {
    foreach(
$rows as $row)
    {
      print 
"<img src='".$row["image_url"]."' />";
    }
  }
?>

If you want to include that into an existing Price Tapestry page, simply remove the require() statement at the top as it will already be included. You could do the same thing on any table that had an "image_url" field - just change the table name in the SQL.

Hope this helps,
David.

Submitted by rolli1 on Wed, 2006-11-01 13:37

Super support as always. Thanks very much again .

Greetings
Roland

Submitted by rolli1 on Wed, 2006-11-01 14:03

Just another little question:
If I want to show pics only from one merchant how would the code be?

$q = sprintf("SELECT image_url FROM `".$config_databaseTablePrefix."products` WHERE merchant='Merchant1' ORDER BY RAND() LIMIT 5");

Roland

Submitted by rolli1 on Wed, 2006-11-01 14:21

No ned for answer. It works. Sorry.

Salutations

Roland

Submitted by rolli1 on Mon, 2006-11-13 07:49

Hi David,

<?php
  
require("includes/common.php");
  
$q sprintf("SELECT image_url FROM `".$config_databaseTablePrefix."products`ORDER BY RAND() LIMIT 5");
  if (
database_querySelect($q,$rows))
  {
    foreach(
$rows as $row)
    {
      print 
"<img src='".$row["image_url"]."' />";
    }
  }
?>

This code works properly. It shows pics only. How can I manage that the pics are clickable to the product url?

Regards

Roland

Submitted by support on Mon, 2006-11-13 09:10

Hi Roland,

Have a go with this....

<?php
  
require("includes/common.php");
  
$q sprintf("SELECT image_url,buy_url FROM `".$config_databaseTablePrefix."products`ORDER BY RAND() LIMIT 5");
  if (
database_querySelect($q,$rows))
  {
    foreach(
$rows as $row)
    {
      print 
"<a href='".$row["buy_url"]."'><img src='".$row["image_url"]."' /></a>";
    }
  }
?>

Cheers,
David.

Submitted by rolli1 on Mon, 2006-11-13 17:33

Sorry David,

this code shows only pics but no links .

Regards
Roland

Submitted by support on Mon, 2006-11-13 22:08

Hi Roland,

Can you email me the URL to the page on your site - the problem should reveal itself in the HTML. If you reply to your reg code or forum registration email is the easiest way...

Cheers,
David.

Submitted by rolli1 on Tue, 2006-11-14 10:28

Hi David,
I emailed you what you wanted to know.

Roland

Submitted by support on Tue, 2006-11-14 10:36

Thanks Roland i'll take a look....

Submitted by rolli1 on Tue, 2006-11-14 10:49

Hi David,
perhaps I have the old version installed. Yesterday I downloaded the new one, but did not install it because I have made a lot of modifications to the code especially in the html folder. Which file should I renew to get the desired result?

Regards

Roland

Submitted by support on Tue, 2006-11-14 13:14

Hi Roland,

It's just the simple pic.php file that I think hasn't been updated - it should contain the following:

<?php
  
require("includes/common.php");
  
$q sprintf("SELECT image_url,buy_url FROM `".$config_databaseTablePrefix."products`ORDER BY RAND() LIMIT 5");
  if (
database_querySelect($q,$rows))
  {
    foreach(
$rows as $row)
    {
      print 
"<a href='".$row["buy_url"]."'><img src='".$row["image_url"]."' /></a>";
    }
  }
?>

...but at the moment it looks like you are still running the older version which doesn't create the links...

Cheers,
David.

Submitted by rolli1 on Tue, 2006-11-14 13:38

Hi David,
I use the provided code in the pics.php:

<?php
require("includes/common.php");
$q sprintf("SELECT buy_url,image_url  FROM `".$config_databaseTablePrefix."products` WHERE merchant='Karmaloop' ORDER BY RAND() LIMIT 5");
if (
database_querySelect($q,$rows))
{
foreach(
$rows as $row)
{
print 
"<a href='".$row["buy_url"]."'><img src='".$row["image_url"]."' /></a>";
}
}
?>

Regards

Roland

Submitted by support on Tue, 2006-11-14 13:51

Hi Roland,

I've just looked at the page again - the link code is definitely not there so i'm not sure what's happening.

Can you email me your pic.php exactly as you have it on your server (please send it as an attachment) and i'll take a look...

Cheers,
David.

Submitted by rolli1 on Tue, 2006-11-14 14:01

You already got it, it is that code I showed above.

Roland

Submitted by support on Tue, 2006-11-14 14:13

Hi Roland,

I'll send you another version to try...

Cheers,
David.

Submitted by rolli1 on Tue, 2006-11-14 14:42

Hi David,

it still shows only pics. I do not have rewrite set to "true", could this make the fault? I can not turn rewrite on.

Regards

Roland

Submitted by support on Tue, 2006-11-14 14:45

Hi Roland,

Can you send me the URL to pics2.php on your server - I just tried it and got a 404....

Cheers,
David.

Submitted by rolli1 on Tue, 2006-11-14 15:10

Hi David,
I use the new code in pics.php not in pics2.php.

Regards
Roland

Submitted by support on Tue, 2006-11-14 15:29

Hello Roland,

I really need you to upload the unmodified version to your server - can you please do this and send me the URL to pics2.php....

Thanks,
David.

Submitted by rolli1 on Tue, 2006-11-14 17:44

Sorry,

I uploaded it under www.drjaycom.net/pics2.php and it works.
Thanks so much and thanks again.

Regards

Roland