Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. $(this).parent(".premium_component_link").attr('href','profile.php?p_id=' + displayImage())
  2.  
  3. <?php $result = $conn->query("SELECT * FROM user_data WHERE advert_type = 'Deluxe'");
  4. if ($result->num_rows > 0) {
  5. while($row = $result->fetch_assoc()) {
  6. $p_id = $row['user_id'];
  7.  
  8. $new_array[$p_id] = $row['user_id'];
  9.  
  10.  
  11. echo '<script>';
  12. echo 'var imagesArray = ' . json_encode($new_array) . ';';
  13. echo '</script>';
  14. ?>
  15.  
  16.  
  17. <script>
  18.  
  19. var usedImages = {};
  20. var usedImagesCount = 0;
  21.  
  22. var imageIndexes = [0,1,2,3,4,5,6,7,8,9,10,11]
  23.  
  24. function displayImage() {
  25. var index = Math.floor(Math.random() * (imageIndexes.length));
  26. var num = imageIndexes[index]
  27.  
  28. var result = imagesArray[num];
  29. imageIndexes.splice(index, 1)
  30.  
  31. if (imageIndexes.length === 0) {
  32. imageIndexes = [0,1,2,3,4,5,6,7,8,9,10,11]
  33. }
  34. return result
  35. }
  36.  
  37.  
  38. function changeImagesSrc() {
  39.  
  40. $(".premium_ad_img").each(function () {
  41. $(this).attr('src','data/profiles/users/profile_img/' + displayImage()) + '/main.jpg')
  42. $(this).parent(".premium_component_link").attr('href','profile.php?p_id=' + displayImage())
  43. }) //End Change IMage
  44.  
  45.  
  46. } //End Function Change
  47.  
  48. $(document).ready(function () {
  49.  
  50. changeImagesSrc()
  51. setInterval(function() {
  52. changeImagesSrc()
  53. }, 5000);
  54. })
  55.  
  56. </script>
  57.  
  58. <? } } ?>
  59.  
  60.  
  61.  
  62. <?php
  63. //Echo out results
  64. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  65. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  66. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  67.  
  68. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  69. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  70. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  71.  
  72. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  73. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  74. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  75.  
  76. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  77. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  78. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  79.  
  80. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  81. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  82. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  83.  
  84. echo '<div class="premium_component"><a href="" class="premium_component_link">';
  85. echo '<img class="premium_ad_img" src="" height="auto" width="auto" />';
  86. echo '<div class=" choose-grid"><h3 class="mt-4">Mark London</h3><p class="">25, London UK</p></div></a></div>';
  87.  
  88.  
  89.  
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement