Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Note that not all servers are configured to regonize PHP's short open tag '<?', so you should always use the full tag '<?php'
- function html_apos($str){ /* Helps to perserve syntax errors with apostrophies in text, by converting to html characters codes */
- return str_replace("'", "'", $str);
- }
- require("includes/connect.php"); // Connects the the datebase
- $id = mysql_real_escape_string( $_GET["id"] ); // SQL Injection Protection
- $sql = "SELECT * FROM project_gallery WHERE id='$id'";
- $result = mysql_query($sql) or die(mysql_error());
- // Without seeing your database setup, I suspect there error is here, with your usage of the database data
- $row = mysql_fetch_array($result);
- $name = $row['name'];
- $location = $row['location'];
- $shortdesc = $row['shortdesc'];
- $photo = $description = $description_title = Array();
- for($i=1;$i<7;++$i){
- $photo[] = $row['photo' . $i];
- $description[] = $row['description' . $i];
- $description_title[] = $row['description_title' . $i];
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <script type="text/javascript">
- var num=0;
- var imgArray = [];
- <?php
- for( $i=0; $i<6; ++$i){
- echo ' ' . 'imgArray[' . $i . "] = ['projects/" . $id . "/" . $photo[$i] . "','" . html_apos($description_title[$i]) . "','" . html_apos($description[$i]) . "'];" . PHP_EOL; // Apostrophies in the descriptions can alter the proper syntax of the arrays, so custom function html_apos() is used to convert them to html character code.
- }
- ?>
- function byId(id){/* Cross Browser getElementById() */
- if (document.layers) {
- return document.layers[id];
- } else if (document.all) {
- return document.all[id];
- } else if (document.getElementById) {
- return document.getElementById(id);
- } else{
- return null;
- }
- }
- function slideshow(dir) {
- num += dir;
- if(num < 0){
- num = imgArray.length - 1;
- }else if( num == imgArray.length){
- num = 0;
- }
- byId('mypic').src = imgArray[num][0];
- byId('title').innerHTML = imgArray[num][1];
- byId('desc').innerHTML = imgArray[num][2];
- return false;
- }
- window.onload = function (){
- slideshow(0);
- }
- </script>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>More infomation on <?php echo $name; ?></title>
- <!-- <link href="includes/gallery_style.css" rel="stylesheet" type="text/css" /> -->
- </head>
- <body>
- <div id="container" style="min-height:400px;">
- <!-- First Image is now loaded by Javascript -->
- <img src="#" id="mypic" name="mypic" border="0">
- <br>
- <!-- Place the text for the first image here -->
- <p id="title"> </p>
- <p id="desc"> </p>
- <p>
- <a href="#" onclick="return slideshow(-1);">« Previous</a> |
- <a href="#" onclick="return slideshow(1);"> Next »</a>
- </p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement