I have been using for a while a class to create photo albums. Shortly, an
array of photo's is declared, initially they are shown as thumbnails, by
clicking on a thumbnail a larger photo is shown and there are links to the
thumbnail list but also to the previous and next photo as the function
remembers which position the photo has got in the array.
Now I tried to do the same thing by retrieving photos from a mysql database
(which is much practical) by searching for filenames that start with a
certain string. It still works but curiously enough the reference to the
next and previous photo fails. Also the indicator "foto 1 van 10", "foto 2
van 10" doesn't work correctly in this variant.
I am not completely sure the error is in one of these functions but I guess
it must have to do with it
This is the code for the array, I used it at
function addThumbnails()//create an array of files to add {
$numargs = func_num_args() ;
$arg_list = func_get_args() ;
//$teller = 0;
for ($i = 0; $i < $numargs; $i++)
{
$this->foto_array[] = $arg_list[$i];
//$teller++;
}
}
//calling the class
$f = new fotoAlbum();
$f->addThumbnails( "foto1.php","fo to2.php",...)
Now the database code I used for
function getFromMySql($b estandspatroon)
{
$this->mysql = true;
$lengte = strlen($bestand spatroon);
$db = mysql_connect(" servername", "login","passwo rd");
mysql_select_db ("database",$db ) or die ("FOUT: OPENEN
DATABASE MISLUKT");
$query = mysql_query("SE LECT bestandsnaam from fotos where
LEFT(bestandsna am, $lengte)='$best andspatroon' order by bestandsnaam ASC",
$db);
while (list($bestands naam) = mysql_fetch_row ($query))
{
$this->foto_array[] = $bestandsnaam;
}
mysql_close($db );
}
//calling the class
$f = new fotoAlbum();
$f->getFromMySql(" ceci2k6")
As you can see on the pages, both pages load a list of thumbnail but the
latter only allows navigation by going to the thumbnail page, not to the
previous or next pages.
Thanks for any suggestions,
Martien,
array of photo's is declared, initially they are shown as thumbnails, by
clicking on a thumbnail a larger photo is shown and there are links to the
thumbnail list but also to the previous and next photo as the function
remembers which position the photo has got in the array.
Now I tried to do the same thing by retrieving photos from a mysql database
(which is much practical) by searching for filenames that start with a
certain string. It still works but curiously enough the reference to the
next and previous photo fails. Also the indicator "foto 1 van 10", "foto 2
van 10" doesn't work correctly in this variant.
I am not completely sure the error is in one of these functions but I guess
it must have to do with it
This is the code for the array, I used it at
function addThumbnails()//create an array of files to add {
$numargs = func_num_args() ;
$arg_list = func_get_args() ;
//$teller = 0;
for ($i = 0; $i < $numargs; $i++)
{
$this->foto_array[] = $arg_list[$i];
//$teller++;
}
}
//calling the class
$f = new fotoAlbum();
$f->addThumbnails( "foto1.php","fo to2.php",...)
Now the database code I used for
function getFromMySql($b estandspatroon)
{
$this->mysql = true;
$lengte = strlen($bestand spatroon);
$db = mysql_connect(" servername", "login","passwo rd");
mysql_select_db ("database",$db ) or die ("FOUT: OPENEN
DATABASE MISLUKT");
$query = mysql_query("SE LECT bestandsnaam from fotos where
LEFT(bestandsna am, $lengte)='$best andspatroon' order by bestandsnaam ASC",
$db);
while (list($bestands naam) = mysql_fetch_row ($query))
{
$this->foto_array[] = $bestandsnaam;
}
mysql_close($db );
}
//calling the class
$f = new fotoAlbum();
$f->getFromMySql(" ceci2k6")
As you can see on the pages, both pages load a list of thumbnail but the
latter only allows navigation by going to the thumbnail page, not to the
previous or next pages.
Thanks for any suggestions,
Martien,
Comment