PX : code

Slide Show by Richard Price
Download this code


<?php

//*************************************************************************
//
//  The php page which uses slideshow.inc should contain at the minimum
//  the following code to set up for and include it:
//
//    $tablename = "slide_table"; // the name of the mysql slide table 
//                                  // $id is an optional query string
//      $slide = ($id)?($id):(1);   // variable used to pass a slide numb.
//                                  // THISPAGE should be replaced with
//      $pagename = THISPAGE;          // the name of the calling page.
//    require("slideshow.inc");   // include this module
//
//
//  The mysql slide table [You can call it what you want.] should be 
//  defined as follows:
//
//    create table <slide_table>(
//    AutoInex tinyint not null auto_increment
//              primary key,
//      Picture varchar(25) not null,
//      Caption text
//    );
//
//**************************************************************************

$server="localhost";     // mysql server address
$dbname="site_list";     // mysql database name
$uid="php";         // username for that database
$pwd="php";         // password for that database

$db mysql_connect($server$uid$pwd);
mysql_select_db($dbname,$db);

$result mysql_query("select AutoIndex from $tablename order by AutoIndex desc",$db);
$lastslide mysql_result($result,0,"AutoIndex");
$slide max($slide,1);
$nextslide = ($slide >= $lastslide)?(1):($slide 1);
$prevslide = ($slide == 1)?($lastslide):($slide-1);

$result mysql_query("select * from $tablename where AutoIndex = $slide",$db);
$picture mysql_result($result,0,"Picture");
$caption mysql_result($result,0,"Caption");

?>

<p align="center">
<img src="<?php echo($picture?>" >
</p>

<?php if($caption!="") { ?>
<p align="center">
<?php echo($caption?>
</p>
<?php ?>

<p align="center">
<A HREF="<?php echo($pagename?>?id=<?php echo($nextslide?>">
<font color="#FF0000" size="6">Next Slide</font></A>
&nbsp;&nbsp;&nbsp;&nbsp;
<A HREF="<?php echo($pagename?>?id=<?php echo($prevslide?>">
<font color="#FF0000" size="6">Previous Slide</font></A>
</p>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.