Guest User

Untitled

a guest
Apr 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <script id="source" language="javascript" type="text/javascript">
  2.  
  3. $(function refreshscreen ()
  4. {
  5.  
  6. $.ajax({
  7. url: 'screen.php',
  8. data: "",
  9. pass to api.php
  10.  
  11. dataType: 'json',
  12. success: function(data)
  13. {
  14. var id = data[0];
  15. var name = data[1];
  16. var votes = data[2];
  17. var video = data[3];
  18. var image = data[4];
  19.  
  20. $('.screen').hide(); $("#video"+id+"").show();
  21.  
  22. var whichvideo = "thevideo" + id;
  23. var videoplay = document.getElementById(whichvideo);
  24. var killvideo = document.getElementsByClassName('videobg');
  25.  
  26.  
  27. var allvideos = document.getElementsByClassName("videobg");
  28.  
  29. for(var x=0; x < allvideos.length; x++)
  30. {
  31.  
  32. var allvideosid = document.getElementById(allvideos[x]);
  33.  
  34. if ($(allvideos[x]).attr("id") == whichvideo) {
  35. allvideos[x].play();
  36. } else {
  37. allvideos[x].pause();
  38. }
  39.  
  40. }
  41.  
  42. },
  43. complete: function() {
  44. // Schedule the next request when the current one's complete
  45. setTimeout(refreshscreen, 5000);
  46. }
  47. });
  48. });
  49.  
  50. <?php
  51.  
  52. $host = "localhost";
  53. $user = "myuserhere";
  54. $pass = "mypasshere";
  55.  
  56. $databaseName = "mydbnamehere";
  57. $tableName = "mytablenamehere";
  58.  
  59.  
  60. $con = mysql_connect($host,$user,$pass);
  61. $dbs = mysql_select_db($databaseName, $con);
  62.  
  63. $result = mysql_query("SELECT * FROM $tableName ORDER BY votes DESC");
  64. $array = mysql_fetch_row($result);
  65.  
  66.  
  67. echo json_encode($array);
  68.  
  69. ?>
Add Comment
Please, Sign In to add comment