Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script id="source" language="javascript" type="text/javascript">
- $(function refreshscreen ()
- {
- $.ajax({
- url: 'screen.php',
- data: "",
- pass to api.php
- dataType: 'json',
- success: function(data)
- {
- var id = data[0];
- var name = data[1];
- var votes = data[2];
- var video = data[3];
- var image = data[4];
- $('.screen').hide(); $("#video"+id+"").show();
- var whichvideo = "thevideo" + id;
- var videoplay = document.getElementById(whichvideo);
- var killvideo = document.getElementsByClassName('videobg');
- var allvideos = document.getElementsByClassName("videobg");
- for(var x=0; x < allvideos.length; x++)
- {
- var allvideosid = document.getElementById(allvideos[x]);
- if ($(allvideos[x]).attr("id") == whichvideo) {
- allvideos[x].play();
- } else {
- allvideos[x].pause();
- }
- }
- },
- complete: function() {
- // Schedule the next request when the current one's complete
- setTimeout(refreshscreen, 5000);
- }
- });
- });
- <?php
- $host = "localhost";
- $user = "myuserhere";
- $pass = "mypasshere";
- $databaseName = "mydbnamehere";
- $tableName = "mytablenamehere";
- $con = mysql_connect($host,$user,$pass);
- $dbs = mysql_select_db($databaseName, $con);
- $result = mysql_query("SELECT * FROM $tableName ORDER BY votes DESC");
- $array = mysql_fetch_row($result);
- echo json_encode($array);
- ?>
Add Comment
Please, Sign In to add comment