PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/performance/index.php

https://bitbucket.org/Jubic/racetrack
PHP | 201 lines | 178 code | 12 blank | 11 comment | 15 complexity | b3762ae36be1b8befbe01b330307465b MD5 | raw file
  1. <?php
  2. include '../dbFunctions.php';
  3. //Get total number of performance
  4. $query = "SELECT COUNT(*) AS total FROM `performance`";
  5. $doquery = mysqli_query($connection, $query);
  6. $row = mysqli_fetch_assoc($doquery);
  7. $total = $row['total'];
  8. $rowperpage = 4; // Maximum icon(row) in one page
  9. $maxpage = ceil($total / $rowperpage);
  10. $pageno = 1; //Default page number
  11. //Clarify page no from the URL
  12. if (isset($_GET['pageno'])) {
  13. $p_no = $_GET['pageno'];
  14. if (is_numeric($p_no) && $p_no > 0 && $p_no <= $maxpage) {
  15. $pageno = $p_no;
  16. }
  17. }
  18. $offset = ($pageno - 1) * $rowperpage;
  19. $query2 = "SELECT * FROM `performance` LIMIT " . $offset . "," . $rowperpage;
  20. $doquery2 = mysqli_query($connection, $query2);
  21. while ($row = mysqli_fetch_assoc($doquery2)) {
  22. $data[] = $row;
  23. }
  24. // Doing paging navigation of Prev, and Next button, and showing the page number of current page
  25. $self = $_SERVER['PHP_SELF'];
  26. $nav = "<p>Showing page <b>" . $pageno . "</b> of <b>" . $maxpage . "</b> pages</p>";
  27. // creating previous and next link
  28. if ($pageno > 1) {
  29. $page = $pageno - 1;
  30. $prev = " <a class='navbutton white' href=\"$self?pageno=$page\">Prev</a> ";
  31. } else {
  32. $prev = '&nbsp;'; // we're on page one, don't print previous link
  33. }
  34. if ($pageno < $maxpage) {
  35. $page = $pageno + 1;
  36. $next = " <a class='navbutton white' href=\"$self?pageno=$page\">Next</a> ";
  37. } else {
  38. $next = '&nbsp;'; // we're on the last page, don't print next link
  39. }
  40. ?>
  41. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  42. <html>
  43. <head>
  44. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  45. <title>Rockwell Automation - Initiatives</title>
  46. <!-- Favicon -->
  47. <link rel="shortcut icon" href="../favicon.ico"/>
  48. <!-- CSS Style -->
  49. <link rel="stylesheet" href="../css/mycss.css" type="text/css" media="screen"/>
  50. <link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection">
  51. <link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
  52. <script type="text/javascript" src="../iepngfix_tilebg.js"></script>
  53. <style type="text/css">
  54. .container{
  55. margin-top: 50px;
  56. color: #fff;
  57. }
  58. h1,h2,h3,h4,h5,h6,p{
  59. color: #fff;
  60. }
  61. .white{
  62. font-size: 30px;
  63. font-variant: normal;
  64. }
  65. .button{
  66. width: 450px;
  67. height: 70px;
  68. padding: 20px 10px;
  69. }
  70. .navbutton{
  71. text-align: center;
  72. width: 100px;
  73. height: 30px;
  74. font: 20px;
  75. font-weight: bold;
  76. padding: 3px 5px 0px;
  77. }
  78. p{
  79. font-size: 16px;
  80. }
  81. a.white{
  82. text-decoration: none;
  83. color: #000;
  84. }
  85. a.visited{
  86. text-decoration: none;
  87. color: gray;
  88. }
  89. a.white:hover{
  90. text-decoration: none;
  91. color: gray;
  92. }
  93. .performance_button{
  94. height: 400px;
  95. }
  96. </style>
  97. <script type="text/javascript" src="../jquery-1.2.6.js"></script>
  98. <script type="text/javascript">
  99. //Timer function
  100. $(document).ready(function() {
  101. /* delay function */
  102. jQuery.fn.delay = function(time,func){
  103. return this.each(function(){
  104. setTimeout(func,time);
  105. });
  106. };
  107. jQuery.fn.countDown = function(settings,to) {
  108. settings = jQuery.extend({
  109. startFontSize: '0px',
  110. endFontSize: '0px',
  111. duration: 1000,
  112. startNumber: 120,
  113. endNumber: 0,
  114. callBack: function() { }
  115. }, settings);
  116. return this.each(function() {
  117. if(!to && to != settings.endNumber) { to = settings.startNumber; }
  118. //set the countdown to the starting number
  119. //$(this).text(to).css('fontSize',settings.startFontSize);
  120. //loopage
  121. $(this).animate({
  122. 'fontSize': settings.endFontSize
  123. },settings.duration,'',function() {
  124. if(to > settings.endNumber + 1) {
  125. $(this).css('fontSize',settings.startFontSize).text(to - 1).countDown(settings,to - 1);
  126. }
  127. else
  128. {
  129. settings.callBack(this);
  130. }
  131. });
  132. });
  133. };
  134. // Below is to activate the above script.
  135. $('#countdown').countDown({
  136. //Change startNumber to suit the duration of the slideshow
  137. startNumber: 300,
  138. callBack: function() {
  139. $(window.location).attr('href','../index.php');
  140. }
  141. });
  142. });
  143. </script>
  144. </head>
  145. <body class="mybackground">
  146. <center>
  147. <div align="center" class="container">
  148. <!-- Performance Data -->
  149. <div class="performance_button">
  150. <?php
  151. if(count($data) <3){
  152. echo "<hr class='space'/><hr class='space'/><hr class='space'/>";
  153. }
  154. foreach ($data as $performance) {
  155. ?>
  156. <div class="span-24">
  157. <a class="button white" href="show_slide.php?id=<?php echo $performance['performance_id']; ?>"><?php echo $performance['performance_name']; ?></a>
  158. </div>
  159. <?php
  160. if(count($data) <4){
  161. echo "<hr class='space'/><hr class='space'/>";
  162. }else{
  163. echo "<hr class='space'/>";
  164. }
  165. }
  166. ?>
  167. </div>
  168. <hr class="space"/>
  169. <!-- Paging Navigation -->
  170. <center>
  171. <div class="span-8"><?php echo $prev; ?></div>
  172. <div class="span-8"><?php echo $nav; ?></div>
  173. <div class="span-8 last"><?php echo $next; ?></div>
  174. </center>
  175. <hr class="space"/>
  176. <!-- Navigation button -->
  177. <center>
  178. <div class="span-12">
  179. <a href="../index.php"><img class="lbutton" alt="home" src="../image/home.png"/></a>
  180. </div>
  181. <div class="span-12 last">
  182. <a href="javascript:javascript:history.go(-1)"><img class="lbutton" src="../image/back.png" alt="back"/></a>
  183. </div>
  184. </center>
  185. </div>
  186. </center>
  187. <span id="countdown"></span>
  188. </body>
  189. </html>