Guest User

Untitled

a guest
Jan 15th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. jQuery(document).ready(function() {
  2. // Get data from Outlast Server
  3. var url="https://outlast.com.au/multi-calc/q_data.php?callback=?";
  4. jQuery.getJSON(url, function(rts_data) {
  5. var deck_count = 0, shiplap_count = 0, bnb_b_count = 0, bnb_c_count = 0;
  6.  
  7. for(var i=0; i<rts_data.length; i++) {
  8. if (rts_data[i].type == "Deck") {
  9. data[0][deck_count] = new Object();
  10. data[0][deck_count].productName = rts_data[i].productName;
  11. data[0][deck_count].coverage = rts_data[i].coverage;
  12. data[0][deck_count].screws = rts_data[i].screws;
  13. data[0][deck_count].gaps = rts_data[i].gaps;
  14.  
  15. // Insert the data into the Select Box
  16. jQuery('#opt_d').append(jQuery('<option>', { value : deck_count }).text(rts_data[i].productName));
  17.  
  18. deck_count++;
  19. }
  20. else if (rts_data[i].type == "Shiplap") {
  21. data[1][shiplap_count] = new Object();
  22. data[1][shiplap_count].productName = rts_data[i].productName;
  23. data[1][shiplap_count].coverage = rts_data[i].coverage;
  24. data[1][shiplap_count].screws = rts_data[i].screws;
  25. data[1][shiplap_count].gaps = rts_data[i].gaps;
  26.  
  27. // Insert the data into the Select Box
  28. jQuery('#opt_s').append(jQuery('<option>', { value : shiplap_count }).text(rts_data[i].productName));
  29.  
  30. shiplap_count++;
  31. }
  32. else if (rts_data[i].type == "Board and Batton - Cap") {
  33. data[2][bnb_c_count] = new Object();
  34. data[2][bnb_c_count].productName = rts_data[i].productName;
  35. data[2][bnb_c_count].coverage = rts_data[i].coverage;
  36. data[2][bnb_c_count].screws = rts_data[i].screws;
  37. data[2][bnb_c_count].gaps = rts_data[i].gaps;
  38.  
  39. // Insert the data into the Select Box
  40. jQuery('#opt_bnb_c').append(jQuery('<option>', { value : bnb_c_count }).text(rts_data[i].productName));
  41.  
  42. bnb_c_count++;
  43. }
  44. else if (rts_data[i].type == "Board and Batton - Base") {
  45. data[3][bnb_b_count] = new Object();
  46. data[3][bnb_b_count].productName = rts_data[i].productName;
  47. data[3][bnb_b_count].coverage = rts_data[i].coverage;
  48. data[3][bnb_b_count].screws = rts_data[i].screws;
  49. data[3][bnb_b_count].gaps = rts_data[i].gaps;
  50.  
  51. // Insert the data into the Select Box
  52. jQuery('#opt_bnb_b').append(jQuery('<option>', { value : bnb_b_count }).text(rts_data[i].productName));
  53.  
  54. bnb_b_count++;
  55. }
  56. }
  57.  
  58. <?php
  59. // Connection data
  60. $host = "xxxxxxx";
  61. $username = "xxxxx";
  62. $database = "xxxxx";
  63. $password = "xxxxx";
  64.  
  65. // Opens a connection to a mySQL server
  66. $connection = mysql_connect ($host, $username, $password);
  67. if (!$connection) {
  68. die("Not connected : " . mysql_error());
  69. }
  70.  
  71. // Set the active mySQL database
  72. $db_selected = mysql_select_db($database, $connection);
  73. if (!$db_selected) {
  74. die ("Can't use db : " . mysql_error());
  75. }
  76.  
  77. // Set the where clause
  78. $where = "";
  79. switch(@$_GET['type']) {
  80. case 'shiplap':
  81. $where = "WHERE type = 'Shiplap'";
  82. break;
  83.  
  84. case 'deck':
  85. $where = "WHERE type = 'Deck'";
  86. break;
  87.  
  88. case 'bnb_base':
  89. $where = "WHERE type = 'Board and Batton - Base'";
  90. break;
  91.  
  92. case 'bnb_cap':
  93. $where = "WHERE type = 'Board and Batton - Cap'";
  94. break;
  95.  
  96. default:
  97. $where = "";
  98. break;
  99. }
  100.  
  101. // Run the query
  102. $query = "SELECT * FROM `site_products` {$where} ORDER BY productID ASC";
  103. $result = mysql_query($query);
  104.  
  105. if (!$result) {
  106. die("Invalid query: " . mysql_error());
  107. }
  108.  
  109. // Declare Variables
  110. $data_shiplap = array();
  111. $shiplap_i = 0;
  112.  
  113. // Get the data and divide
  114. while ($row = @mysql_fetch_assoc($result)) {
  115. $data_shiplap[$shiplap_i]['productName'] = $row['productName'];
  116. $data_shiplap[$shiplap_i]['coverage'] = $row['coverage'];
  117. $data_shiplap[$shiplap_i]['screws'] = $row['screws'];
  118. $data_shiplap[$shiplap_i]['gaps'] = $row['gaps'];
  119. $data_shiplap[$shiplap_i]['type'] = $row['type'];
  120.  
  121. $shiplap_i++;
  122. }
  123.  
  124. echo $_GET['callback']. '('. json_encode($data_shiplap) . ')';
  125. ?>
Add Comment
Please, Sign In to add comment