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
Hi David,
yes, I meant that the urls of the pics are stored.
ROland
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.
Super support as always. Thanks very much again .
Greetings
Roland
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
No ned for answer. It works. Sorry.
Salutations
Roland
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
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.
Sorry David,
this code shows only pics but no links .
Regards
Roland
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.
Hi David,
I emailed you what you wanted to know.
Roland
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
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.
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
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.
You already got it, it is that code I showed above.
Roland
Hi Roland,
I'll send you another version to try...
Cheers,
David.
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
Hi Roland,
Can you send me the URL to pics2.php on your server - I just tried it and got a 404....
Cheers,
David.
Hi David,
I use the new code in pics.php not in pics2.php.
Regards
Roland
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.
Sorry,
I uploaded it under www.drjaycom.net/pics2.php and it works.
Thanks so much and thanks again.
Regards
Roland
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?