home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / slidesh.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  2.4 KB  |  71 lines

  1. Slide Show 
  2.  
  3. This include file creates a slide show using pictures pointed to by a mysql database. The database can contain an optional caption which is displayed under the picture. 
  4.  
  5.  
  6.  
  7. <?php 
  8.  
  9. //************************************************************************* 
  10. // 
  11. //  The php page which uses slideshow.inc should contain at the minimum 
  12. //  the following code to set up for and include it: 
  13. // 
  14. //    $tablename = "slide_table"; // the name of the mysql slide table  
  15. //                                  // $id is an optional query string 
  16. //      $slide = ($id)?($id):(1);   // variable used to pass a slide numb. 
  17. //                                  // THISPAGE should be replaced with 
  18. //      $pagename = THISPAGE;          // the name of the calling page. 
  19. //    require("slideshow.inc");   // include this module 
  20. // 
  21. // 
  22. //  The mysql slide table [You can call it what you want.] should be  
  23. //  defined as follows: 
  24. // 
  25. //    create table <slide_table>( 
  26. //    AutoInex tinyint not null auto_increment 
  27. //              primary key, 
  28. //      Picture varchar(25) not null, 
  29. //      Caption text 
  30. //    ); 
  31. // 
  32. //************************************************************************** 
  33.  
  34. $server= "localhost";      // mysql server address 
  35. $dbname= "site_list";      // mysql database name 
  36. $uid= "php";          // username for that database 
  37. $pwd= "php";          // password for that database 
  38.  
  39. $db = mysql_connect($server, $uid, $pwd); 
  40. mysql_select_db($dbname,$db); 
  41.  
  42. $result = mysql_query( "select AutoIndex from $tablename order by AutoIndex desc",$db); 
  43. $lastslide = mysql_result($result,0, "AutoIndex"); 
  44. $slide = max($slide,1); 
  45. $nextslide = ($slide >= $lastslide)?(1):($slide + 1); 
  46. $prevslide = ($slide == 1)?($lastslide):($slide-1); 
  47.  
  48. $result = mysql_query( "select * from $tablename where AutoIndex = $slide",$db); 
  49. $picture = mysql_result($result,0, "Picture"); 
  50. $caption = mysql_result($result,0, "Caption"); 
  51.  
  52. ?> 
  53.  
  54. <p align="center"> 
  55. <img src=" <?php echo($picture) ?>" > 
  56. </p> 
  57.  
  58. <?php if($caption!= "") { ?> 
  59. <p align="center"> 
  60. <?php echo($caption) ?> 
  61. </p> 
  62. <?php } ?> 
  63.  
  64. <p align="center"> 
  65. <A HREF=" <?php echo($pagename) ?>?id= <?php echo($nextslide) ?>"> 
  66. <font color="#FF0000" size="6">Next Slide</font></A> 
  67.      
  68. <A HREF=" <?php echo($pagename) ?>?id= <?php echo($prevslide) ?>"> 
  69. <font color="#FF0000" size="6">Previous Slide</font></A> 
  70. </p>
  71.