Guest User

Untitled

a guest
Sep 29th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.72 KB | None | 0 0
  1.  
  2. <?php
  3. /*** mysql hostname ***/
  4. $hostname = 'localhost';
  5.  
  6. /*** mysql username ***/
  7. $username = 'root';
  8.  
  9. /*** mysql password ***/
  10. $password = 'root';
  11.  
  12. try {
  13. $dbh = new PDO("mysql:host=$hostname;dbname=WeatherStation", $username, $password);
  14. /*** echo a message saying we have connected ***/
  15. //echo 'Connected to database<br />';
  16.  
  17. /*** The SQL SELECT statement ***/
  18. $sql = "SELECT data FROM ProcTest";
  19.  
  20. /*** fetch into an PDOStatement object ***/
  21. $stmt = $dbh->query($sql);
  22.  
  23. /*** echo number of columns ***/
  24. $result = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  25.  
  26. /*** loop over the object directly ***/
  27.  
  28. for($i = 0; $i<5; $i++){
  29. var_dump($result[$i]);
  30. }
  31.  
  32. /*** close the database connection ***/
  33. $dbh = null;
  34. }
  35. catch(PDOException $e)
  36. {
  37. echo $e->getMessage();
  38. }
  39.  
  40. ?><!DOCTYPE html>
  41. <html>
  42. <head>
  43. <audio id="audOne" preload="auto">
  44. <source src="audio/one.mp3"></source>
  45. <!--<source src="audio/one.ogg"></source>-->
  46. <source src="audio/one.wav"></source>
  47. Your browser isn't invited for super fun time.
  48. </audio>
  49.  
  50.  
  51. <audio id="audTwo" preload="auto">
  52. <source src="audio/two.mp3"></source>
  53. <!--<source src="audio/two.ogg"></source>-->
  54. <source src="audio/two.wav"></source>
  55. Your browser isn't invited for super fun time.
  56. </audio>
  57.  
  58. <audio id="audThree" preload="auto">
  59. <source src="audio/three.mp3"></source>
  60. <!--<source src="audio/three.ogg"></source>-->
  61. <source src="audio/three.wav"></source>
  62. Your browser isn't invited for super fun time.
  63. </audio>
  64.  
  65. <audio id="audFour" preload="auto">
  66. <source src="audio/four.mp3"></source>
  67. <!--<source src="audio/four.ogg"></source>-->
  68. <source src="audio/four.wav"></source>
  69. Your browser isn't invited for super fun time.
  70. </audio>
  71.  
  72. <audio id="audFive" preload="auto">
  73. <source src="audio/five.mp3"></source>
  74. <!--<source src="audio/five.ogg"></source>-->
  75. <source src="audio/five.wav"></source>
  76. Your browser isn't invited for super fun time.
  77. </audio>
  78.  
  79. <audio id="audSix" preload="auto">
  80. <source src="audio/six.mp3"></source>
  81. <!--<source src="audio/six.ogg"></source>-->
  82. <source src="audio/six.wav"></source>
  83. Your browser isn't invited for super fun time.
  84. </audio>
  85.  
  86.  
  87. <audio id="audSeven" preload="auto">
  88. <source src="audio/seven.mp3"></source>
  89. <!--<source src="audio/seven.ogg"></source>-->
  90. <source src="audio/seven.wav"></source>
  91. Your browser isn't invited for super fun time.
  92. </audio>
  93.  
  94. <audio id="audEight" preload="auto">
  95. <source src="audio/eight.mp3"></source>
  96. <!--<source src="audio/eight.ogg"></source>-->
  97. <source src="audio/eight.wav"></source>
  98. Your browser isn't invited for super fun time.
  99. </audio>
  100.  
  101. <audio id="audNine" preload="auto">
  102. <source src="audio/nine.mp3"></source>
  103. <!--<source src="audio/nine.ogg"></source>-->
  104. <source src="audio/nine.wav"></source>
  105. Your browser isn't invited for super fun time.
  106. </audio>
  107.  
  108. <audio id="audTen" preload="auto">
  109. <source src="audio/ten.mp3"></source>
  110. <!--<source src="audio/ten.ogg"></source>-->
  111. <source src="audio/ten.wav"></source>
  112. Your browser isn't invited for super fun time.
  113. </audio>
  114. <script type="text/javascript" src="jquery-1.8.0.js"></script>
  115. <script type="text/javascript">
  116. var dataArray = new Array();
  117. dataArray = <?php echo json_encode($result);?>;
  118. var i;
  119.  
  120. var percentageArray = new Array();
  121. for (var i=0; i<10; i++){
  122. percentageArray[i] = ((dataArray[i]/100)*100);
  123. }
  124.  
  125. function makeX(sensorValue){
  126. var x;
  127. if((sensorValue >= 0) && (sensorValue <= 10)){
  128. x=0;
  129. }
  130. if((sensorValue > 10) && (sensorValue <= 20)){
  131. x=1;
  132. }
  133. if((sensorValue > 20) && (sensorValue <= 30)){
  134. x=2;
  135. }
  136. if((sensorValue > 30) && (sensorValue <= 40)){
  137. x=3;
  138. }
  139. if((sensorValue > 40) && (sensorValue <= 50)){
  140. x=4;
  141. }
  142. if((sensorValue > 50) && (sensorValue <= 60)){
  143. x=2;
  144. }
  145. if((sensorValue > 60) && (sensorValue <= 70)){
  146. x=3;
  147. }
  148. if((sensorValue > 70) && (sensorValue <= 80)){
  149. x=3;
  150. }
  151. if((sensorValue > 80) && (sensorValue <= 90)){
  152. x=3;
  153. }
  154. if((sensorValue > 90) && (sensorValue <= 100)){
  155. x=3;
  156. }
  157. return x;
  158. }
  159.  
  160. function chooseSound(sensorValue){
  161. if((sensorValue >= 0) && (sensorValue <= 10)){
  162. var soundOne = $("#audOne")[0];
  163. return soundOne.play();
  164. }
  165. if((sensorValue > 10) && (sensorValue <= 20)){
  166. var soundTwo = $("#audTwo")[0];
  167. return soundTwo.play();
  168. }
  169. if((sensorValue > 20) && (sensorValue <= 30)){
  170. var soundThree = $("#audThree")[0];
  171. return soundThree.play();
  172. }
  173. if((sensorValue > 30) && (sensorValue <= 40)){
  174. var soundFour = $("#audFour")[0];
  175. return soundFour.play();
  176. }
  177. if((sensorValue > 40) && (sensorValue <= 50)){
  178. var soundFive = $("#audFive")[0];
  179. return soundFive.play();
  180. }
  181. if((sensorValue > 50) && (sensorValue <= 60)){
  182. var soundSix = $("#audSix")[0];
  183. return soundSix.play();
  184. }
  185. if((sensorValue > 60) && (sensorValue <= 70)){
  186. var soundSeven = $("#audSeven")[0];
  187. return soundSeven.play();
  188. }
  189. if((sensorValue > 70) && (sensorValue <= 80)){
  190. var soundEight = $("#audEight")[0];
  191. return soundEight.play();
  192. }
  193. if((sensorValue > 80) && (sensorValue <= 90)){
  194. var soundNine = $("#audNine")[0];
  195. return soundNine.play();
  196. }
  197. if((sensorValue > 90) && (sensorValue <= 100)){
  198. var soundTen = $("#audTen")[0];
  199. return soundTen.play();
  200. }
  201. }
  202.  
  203. $(document).ready(function(){
  204.  
  205. $("img").click(function(){
  206. if(makeX(percentageArray[0])==0){
  207. $(".first").after('<img class= "first" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  208. $(".first").click(function(){
  209. chooseSound(percentageArray[0]);
  210. });
  211. }else {
  212. for(var j=0; j<=(makeX(percentageArray[0])); j++){
  213. $(".first").after('<img class= "first" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  214. $(".first").click(function(){
  215. chooseSound(percentageArray[0]);
  216. });
  217. }
  218. }
  219.  
  220. if(makeX(percentageArray[1])==0){
  221. $(".second").after('<img class= "second" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  222. $(".second").click(function(){
  223. chooseSound(percentageArray[1]);
  224. });
  225. }else {
  226. for(var k=0; k<=(makeX(percentageArray[1])); k++){
  227. $(".second").after('<img class= "second" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  228. $(".second").click(function(){
  229. chooseSound(percentageArray[1]);
  230. });
  231. }
  232. }
  233.  
  234. if(makeX(percentageArray[2])==0){
  235. $(".third").after('<img class= "third" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  236. $(".third").click(function(){
  237. chooseSound(percentageArray[2]);
  238. });
  239. }else {
  240. for(var l=0; l<=(makeX(percentageArray[2])); l++){
  241. $(".third").after('<img class= "third" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  242. $(".third").click(function(){
  243. chooseSound(percentageArray[2]);
  244. });
  245. }
  246. }
  247.  
  248. if(makeX(percentageArray[3])==0){
  249. $(".fourth").after('<img class= "fourth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  250. $(".fourth").click(function(){
  251. chooseSound(percentageArray[3]);
  252. });
  253. }else {
  254. for(var m=0; m<=(makeX(percentageArray[3])); m++){
  255. $(".fourth").after('<img class= "fourth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  256. $(".fourth").click(function(){
  257. chooseSound(percentageArray[3]);
  258. });
  259. }
  260. }
  261. if(makeX(percentageArray[4])==0){
  262. $(".fifth").after('<img class= "fifth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  263. $(".fifth").click(function(){
  264. chooseSound(percentageArray[4]);
  265. });
  266. }else {
  267. for(var n=0; n<=(makeX(percentageArray[4])); n++){
  268. $(".fifth").after('<img class= "fifth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  269. $(".fifth").click(function(){
  270. chooseSound(percentageArray[4]);
  271. });
  272. }
  273. }
  274. if(makeX(percentageArray[5])==0){
  275. $(".sixth").after('<img class= "sixth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  276. $(".sixth").click(function(){
  277. chooseSound(percentageArray[5]);
  278. });
  279. }else {
  280. for(var o=0; o<=(makeX(percentageArray[5])); 0++){
  281. $(".sixth").after('<img class= "sixth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  282. $(".sixth").click(function(){
  283. chooseSound(percentageArray[5]);
  284. });
  285. }
  286. }
  287. if(makeX(percentageArray[6])==0){
  288. $(".seventh").after('<img class= "seventh" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  289. $(".seventh").click(function(){
  290. chooseSound(percentageArray[6]);
  291. });
  292. }else {
  293. for(var p=0; p<=(makeX(percentageArray[6])); p++){
  294. $(".seventh").after('<img class= "seventh" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  295. $(".seventh").click(function(){
  296. chooseSound(percentageArray[6]);
  297. });
  298. }
  299. }
  300. if(makeX(percentageArray[7])==0){
  301. $(".eighth").after('<img class= "eighth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  302. $(".eighth").click(function(){
  303. chooseSound(percentageArray[7]);
  304. });
  305. }else {
  306. for(var q=0; q<=(makeX(percentageArray[7])); q++){
  307. $(".eighth").after('<img class= "eighth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  308. $(".eighth").click(function(){
  309. chooseSound(percentageArray[7]);
  310. });
  311. }
  312. }
  313. if(makeX(percentageArray[8])==0){
  314. $(".ninth").after('<img class= "ninth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  315. $(".ninth").click(function(){
  316. chooseSound(percentageArray[8]);
  317. });
  318. }else {
  319. for(var r=0; r<=(makeX(percentageArray[8])); r++){
  320. $(".ninth").after('<img class= "ninth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
  321. $(".ninth").click(function(){
  322. chooseSound(percentageArray[8]);
  323. });
  324. }
  325. }
  326. if(makeX(percentageArray[9])==0){
  327. $(".tenth").after('<img class= "tenth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  328. $(".tenth").click(function(){
  329. chooseSound(percentageArray[9]);
  330. });
  331. }else {
  332. for(var n=0; n<=(makeX(percentageArray[9])); n++){
  333. $(".tenth").after('<img class= "tenth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
  334. $(".tenth").click(function(){
  335. chooseSound(percentageArray[9]);
  336. });
  337. }
  338. }
  339.  
  340.  
  341. });
  342.  
  343.  
  344. for(i=0; i<10; i++){
  345. chooseSound(percentageArray[i]);
  346. }
  347.  
  348.  
  349.  
  350. });
  351. </script>
  352.  
  353. <style type="text/css">
  354. #container {
  355. width: 100%
  356. background: #FFF;
  357. margin: 0 auto; /* the auto value on the
  358. sides, coupled with the width, centres the
  359. layout */}
  360. img {
  361. width:60%;
  362. height:10%;
  363. margin:5px;
  364.  
  365. }
  366. #leftside { width: 50%; float: left; }
  367. #rightside { width: 50%; float: right; }
  368. .leftsideleft {width: 60%; float: left; }
  369. .leftsideright {width: 40%; float: right; }
  370.  
  371. .leftcolumn {width: 66.65%; float: left; }
  372. #thirdcolumn {width: 33.33%; float: right; }
  373. #eighthcolumn {width: 33.33%; float: right; }
  374.  
  375. #firstcolumn {width: 50%; float: left; }
  376. #secondcolumn {width: 50%; float: right; }
  377. #fourthcolumn {width: 50%; float: left; }
  378. #fifthcolumn {width: 50%; float: right; }
  379.  
  380. #sixthcolumn {width: 50%; float: left; }
  381. #seventhcolumn {width: 50%; float: right; }
  382. #ninthcolumn {width: 50%; float: left; }
  383. #tenthcolumn {width: 50%; float: right; }
  384.  
  385.  
  386. </style>
  387. </head>
  388. <body>
  389. <div id="container">
  390. <div id="leftside">
  391. <div class="leftsideleft">
  392. <div class="leftcolumn">
  393. <div id="firstcolumn"><img class= "first" src="darkDrops.png" alt="Water droplets" /></div>
  394. <div id="secondcolumn"><img class= "second" src="lightDrops.png" alt="Water droplets" /></div>
  395. </div>
  396. <div id="thirdcolumn"><img class= "third" src="darkDrops.png" alt="Water droplets" /></div>
  397. </div>
  398. <div class="leftsideright">
  399. <div id="fourthcolumn"><img class= "fourth" src="lightDrops.png" alt="Water droplets" /></div>
  400. <div id="fifthcolumn"><img class= "fifth" src="darkDrops.png" alt="Water droplets" /></div>
  401. </div>
  402. </div>
  403. <div id="rightside">
  404. <div class="leftsideleft">
  405. <div class="leftcolumn">
  406. <div id="sixthcolumn"><img class= "sixth" src="lightDrops.png" alt="Water droplets" /></div>
  407. <div id="seventhcolumn"><img class= "seventh" src="darkDrops.png" alt="Water droplets" /></div>
  408. </div>
  409. <div id="eighthcolumn"><img class= "eighth" src="lightDrops.png" alt="Water droplets" /></div>
  410. </div>
  411. <div class="leftsideright">
  412. <div id="ninthcolumn"><img class= "ninth" src="darkDrops.png" alt="Water droplets" /></div>
  413. <div id="tenthcolumn"><img class= "tenth" src="lightDrops.png" alt="Water droplets" /></div>
  414. </div>
  415. </div>
  416.  
  417.  
  418.  
  419.  
  420. </div>
  421. </div>
  422.  
  423. </body>
  424. </html>
Add Comment
Please, Sign In to add comment