?foru
07-12-2008, 08:26 PM
1) Script Title: Ultimate Fade-in slideshow (v1.51)
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
I located here: http://www.dynamicdrive.com/forums/showthread.php?t=10016 a php script written to grab all available photos in a directory. Thank you
Twey! The following works perfectly.
<?php
// getpics.php
$directory = "slideshow"; // Directory in which the images are stored, relative to the location of this script. Must have the slash.
header("Content-Type: text/javascript");
$dir = opendir($directory);
for($i=0;$file = readdir($dir);$i++)
if(strpos($file, ".") === 0) {
$i--;
continue;
} else echo("fadeimages[$i]=['$directory/$file', 'http://example.com/products.php', ''];\n");
?>
My question is that I have been try to get this to pull from a mySQL table, and I can't seem to get it to work.
<?php
$db_username = "I connect to db ok"; // Your database login username
$db_password = "I connect to db ok"; // Your database login password
$db_name = "I connect to db ok"; // The name of the database you wish to use
$db_host = "I connect to db ok"; // The address of the database. Often this is localhost, but may be for example db.yoursite.com
$tbl_name = "slideshow"; // The name of your table in the database
$fadebgcolor = "black"; // The color you would like to display in slideshow background - #000000 will also work
$dbh=mysql_connect($db_host, $db_username, $db_password) or die ('You need to set your database connection in this file.</td></tr></table></body></html>');
mysql_select_db($db_name) or die ('You need to set your database connection in this file.</td></tr></table></body></html>');
//display all the items from database
$query = "SELECT * FROM $tbl_name ORDER BY id";
$result = mysql_query($query);
//while(list($id,$image,$link)= mysql_fetch_row($result))
//{
$id=$r["id"];
$image=$r["image"];
$link=$r["link"];
for( $i = 0; $i < $row = $r=mysql_fetch_array($query); $i++)
{
header("Content-Type: text/javascript");
echo "fadeimages[".$row["id"]."]=['".$row["image"]."', '".$row["link"]."', ''];\n";
}
?>
The reason for the database is so that the enduser can use an update page to change the links and images if they sell a product that is featured in the fading slideshow. I've tried the "for" and "while", but I must be overlooking something. I would greatly appreciate if someone had a suggestion/solution.
Thank you
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
I located here: http://www.dynamicdrive.com/forums/showthread.php?t=10016 a php script written to grab all available photos in a directory. Thank you
Twey! The following works perfectly.
<?php
// getpics.php
$directory = "slideshow"; // Directory in which the images are stored, relative to the location of this script. Must have the slash.
header("Content-Type: text/javascript");
$dir = opendir($directory);
for($i=0;$file = readdir($dir);$i++)
if(strpos($file, ".") === 0) {
$i--;
continue;
} else echo("fadeimages[$i]=['$directory/$file', 'http://example.com/products.php', ''];\n");
?>
My question is that I have been try to get this to pull from a mySQL table, and I can't seem to get it to work.
<?php
$db_username = "I connect to db ok"; // Your database login username
$db_password = "I connect to db ok"; // Your database login password
$db_name = "I connect to db ok"; // The name of the database you wish to use
$db_host = "I connect to db ok"; // The address of the database. Often this is localhost, but may be for example db.yoursite.com
$tbl_name = "slideshow"; // The name of your table in the database
$fadebgcolor = "black"; // The color you would like to display in slideshow background - #000000 will also work
$dbh=mysql_connect($db_host, $db_username, $db_password) or die ('You need to set your database connection in this file.</td></tr></table></body></html>');
mysql_select_db($db_name) or die ('You need to set your database connection in this file.</td></tr></table></body></html>');
//display all the items from database
$query = "SELECT * FROM $tbl_name ORDER BY id";
$result = mysql_query($query);
//while(list($id,$image,$link)= mysql_fetch_row($result))
//{
$id=$r["id"];
$image=$r["image"];
$link=$r["link"];
for( $i = 0; $i < $row = $r=mysql_fetch_array($query); $i++)
{
header("Content-Type: text/javascript");
echo "fadeimages[".$row["id"]."]=['".$row["image"]."', '".$row["link"]."', ''];\n";
}
?>
The reason for the database is so that the enduser can use an update page to change the links and images if they sell a product that is featured in the fading slideshow. I've tried the "for" and "while", but I must be overlooking something. I would greatly appreciate if someone had a suggestion/solution.
Thank you