Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*** mysql hostname ***/
- $hostname = 'localhost';
- /*** mysql username ***/
- $username = 'root';
- /*** mysql password ***/
- $password = 'root';
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=WeatherStation", $username, $password);
- /*** echo a message saying we have connected ***/
- //echo 'Connected to database<br />';
- /*** The SQL SELECT statement ***/
- $sql = "SELECT data FROM ProcTest";
- /*** fetch into an PDOStatement object ***/
- $stmt = $dbh->query($sql);
- /*** echo number of columns ***/
- $result = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
- /*** loop over the object directly ***/
- for($i = 0; $i<5; $i++){
- var_dump($result[$i]);
- }
- /*** close the database connection ***/
- $dbh = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- ?><!DOCTYPE html>
- <html>
- <head>
- <audio id="audOne" preload="auto">
- <source src="audio/one.mp3"></source>
- <!--<source src="audio/one.ogg"></source>-->
- <source src="audio/one.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audTwo" preload="auto">
- <source src="audio/two.mp3"></source>
- <!--<source src="audio/two.ogg"></source>-->
- <source src="audio/two.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audThree" preload="auto">
- <source src="audio/three.mp3"></source>
- <!--<source src="audio/three.ogg"></source>-->
- <source src="audio/three.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audFour" preload="auto">
- <source src="audio/four.mp3"></source>
- <!--<source src="audio/four.ogg"></source>-->
- <source src="audio/four.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audFive" preload="auto">
- <source src="audio/five.mp3"></source>
- <!--<source src="audio/five.ogg"></source>-->
- <source src="audio/five.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audSix" preload="auto">
- <source src="audio/six.mp3"></source>
- <!--<source src="audio/six.ogg"></source>-->
- <source src="audio/six.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audSeven" preload="auto">
- <source src="audio/seven.mp3"></source>
- <!--<source src="audio/seven.ogg"></source>-->
- <source src="audio/seven.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audEight" preload="auto">
- <source src="audio/eight.mp3"></source>
- <!--<source src="audio/eight.ogg"></source>-->
- <source src="audio/eight.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audNine" preload="auto">
- <source src="audio/nine.mp3"></source>
- <!--<source src="audio/nine.ogg"></source>-->
- <source src="audio/nine.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <audio id="audTen" preload="auto">
- <source src="audio/ten.mp3"></source>
- <!--<source src="audio/ten.ogg"></source>-->
- <source src="audio/ten.wav"></source>
- Your browser isn't invited for super fun time.
- </audio>
- <script type="text/javascript" src="jquery-1.8.0.js"></script>
- <script type="text/javascript">
- var dataArray = new Array();
- dataArray = <?php echo json_encode($result);?>;
- var i;
- var percentageArray = new Array();
- for (var i=0; i<10; i++){
- percentageArray[i] = ((dataArray[i]/100)*100);
- }
- function makeX(sensorValue){
- var x;
- if((sensorValue >= 0) && (sensorValue <= 10)){
- x=0;
- }
- if((sensorValue > 10) && (sensorValue <= 20)){
- x=1;
- }
- if((sensorValue > 20) && (sensorValue <= 30)){
- x=2;
- }
- if((sensorValue > 30) && (sensorValue <= 40)){
- x=3;
- }
- if((sensorValue > 40) && (sensorValue <= 50)){
- x=4;
- }
- if((sensorValue > 50) && (sensorValue <= 60)){
- x=2;
- }
- if((sensorValue > 60) && (sensorValue <= 70)){
- x=3;
- }
- if((sensorValue > 70) && (sensorValue <= 80)){
- x=3;
- }
- if((sensorValue > 80) && (sensorValue <= 90)){
- x=3;
- }
- if((sensorValue > 90) && (sensorValue <= 100)){
- x=3;
- }
- return x;
- }
- function chooseSound(sensorValue){
- if((sensorValue >= 0) && (sensorValue <= 10)){
- var soundOne = $("#audOne")[0];
- return soundOne.play();
- }
- if((sensorValue > 10) && (sensorValue <= 20)){
- var soundTwo = $("#audTwo")[0];
- return soundTwo.play();
- }
- if((sensorValue > 20) && (sensorValue <= 30)){
- var soundThree = $("#audThree")[0];
- return soundThree.play();
- }
- if((sensorValue > 30) && (sensorValue <= 40)){
- var soundFour = $("#audFour")[0];
- return soundFour.play();
- }
- if((sensorValue > 40) && (sensorValue <= 50)){
- var soundFive = $("#audFive")[0];
- return soundFive.play();
- }
- if((sensorValue > 50) && (sensorValue <= 60)){
- var soundSix = $("#audSix")[0];
- return soundSix.play();
- }
- if((sensorValue > 60) && (sensorValue <= 70)){
- var soundSeven = $("#audSeven")[0];
- return soundSeven.play();
- }
- if((sensorValue > 70) && (sensorValue <= 80)){
- var soundEight = $("#audEight")[0];
- return soundEight.play();
- }
- if((sensorValue > 80) && (sensorValue <= 90)){
- var soundNine = $("#audNine")[0];
- return soundNine.play();
- }
- if((sensorValue > 90) && (sensorValue <= 100)){
- var soundTen = $("#audTen")[0];
- return soundTen.play();
- }
- }
- $(document).ready(function(){
- $("img").click(function(){
- if(makeX(percentageArray[0])==0){
- $(".first").after('<img class= "first" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".first").click(function(){
- chooseSound(percentageArray[0]);
- });
- }else {
- for(var j=0; j<=(makeX(percentageArray[0])); j++){
- $(".first").after('<img class= "first" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".first").click(function(){
- chooseSound(percentageArray[0]);
- });
- }
- }
- if(makeX(percentageArray[1])==0){
- $(".second").after('<img class= "second" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".second").click(function(){
- chooseSound(percentageArray[1]);
- });
- }else {
- for(var k=0; k<=(makeX(percentageArray[1])); k++){
- $(".second").after('<img class= "second" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".second").click(function(){
- chooseSound(percentageArray[1]);
- });
- }
- }
- if(makeX(percentageArray[2])==0){
- $(".third").after('<img class= "third" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".third").click(function(){
- chooseSound(percentageArray[2]);
- });
- }else {
- for(var l=0; l<=(makeX(percentageArray[2])); l++){
- $(".third").after('<img class= "third" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".third").click(function(){
- chooseSound(percentageArray[2]);
- });
- }
- }
- if(makeX(percentageArray[3])==0){
- $(".fourth").after('<img class= "fourth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".fourth").click(function(){
- chooseSound(percentageArray[3]);
- });
- }else {
- for(var m=0; m<=(makeX(percentageArray[3])); m++){
- $(".fourth").after('<img class= "fourth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".fourth").click(function(){
- chooseSound(percentageArray[3]);
- });
- }
- }
- if(makeX(percentageArray[4])==0){
- $(".fifth").after('<img class= "fifth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".fifth").click(function(){
- chooseSound(percentageArray[4]);
- });
- }else {
- for(var n=0; n<=(makeX(percentageArray[4])); n++){
- $(".fifth").after('<img class= "fifth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".fifth").click(function(){
- chooseSound(percentageArray[4]);
- });
- }
- }
- if(makeX(percentageArray[5])==0){
- $(".sixth").after('<img class= "sixth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".sixth").click(function(){
- chooseSound(percentageArray[5]);
- });
- }else {
- for(var o=0; o<=(makeX(percentageArray[5])); 0++){
- $(".sixth").after('<img class= "sixth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".sixth").click(function(){
- chooseSound(percentageArray[5]);
- });
- }
- }
- if(makeX(percentageArray[6])==0){
- $(".seventh").after('<img class= "seventh" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".seventh").click(function(){
- chooseSound(percentageArray[6]);
- });
- }else {
- for(var p=0; p<=(makeX(percentageArray[6])); p++){
- $(".seventh").after('<img class= "seventh" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".seventh").click(function(){
- chooseSound(percentageArray[6]);
- });
- }
- }
- if(makeX(percentageArray[7])==0){
- $(".eighth").after('<img class= "eighth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".eighth").click(function(){
- chooseSound(percentageArray[7]);
- });
- }else {
- for(var q=0; q<=(makeX(percentageArray[7])); q++){
- $(".eighth").after('<img class= "eighth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".eighth").click(function(){
- chooseSound(percentageArray[7]);
- });
- }
- }
- if(makeX(percentageArray[8])==0){
- $(".ninth").after('<img class= "ninth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".ninth").click(function(){
- chooseSound(percentageArray[8]);
- });
- }else {
- for(var r=0; r<=(makeX(percentageArray[8])); r++){
- $(".ninth").after('<img class= "ninth" src="darkDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".ninth").click(function(){
- chooseSound(percentageArray[8]);
- });
- }
- }
- if(makeX(percentageArray[9])==0){
- $(".tenth").after('<img class= "tenth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".tenth").click(function(){
- chooseSound(percentageArray[9]);
- });
- }else {
- for(var n=0; n<=(makeX(percentageArray[9])); n++){
- $(".tenth").after('<img class= "tenth" src="lightDrops.png" alt="Water droplets" width="60" height="60" />');
- $(".tenth").click(function(){
- chooseSound(percentageArray[9]);
- });
- }
- }
- });
- for(i=0; i<10; i++){
- chooseSound(percentageArray[i]);
- }
- });
- </script>
- <style type="text/css">
- #container {
- width: 100%
- background: #FFF;
- margin: 0 auto; /* the auto value on the
- sides, coupled with the width, centres the
- layout */}
- img {
- width:60%;
- height:10%;
- margin:5px;
- }
- #leftside { width: 50%; float: left; }
- #rightside { width: 50%; float: right; }
- .leftsideleft {width: 60%; float: left; }
- .leftsideright {width: 40%; float: right; }
- .leftcolumn {width: 66.65%; float: left; }
- #thirdcolumn {width: 33.33%; float: right; }
- #eighthcolumn {width: 33.33%; float: right; }
- #firstcolumn {width: 50%; float: left; }
- #secondcolumn {width: 50%; float: right; }
- #fourthcolumn {width: 50%; float: left; }
- #fifthcolumn {width: 50%; float: right; }
- #sixthcolumn {width: 50%; float: left; }
- #seventhcolumn {width: 50%; float: right; }
- #ninthcolumn {width: 50%; float: left; }
- #tenthcolumn {width: 50%; float: right; }
- </style>
- </head>
- <body>
- <div id="container">
- <div id="leftside">
- <div class="leftsideleft">
- <div class="leftcolumn">
- <div id="firstcolumn"><img class= "first" src="darkDrops.png" alt="Water droplets" /></div>
- <div id="secondcolumn"><img class= "second" src="lightDrops.png" alt="Water droplets" /></div>
- </div>
- <div id="thirdcolumn"><img class= "third" src="darkDrops.png" alt="Water droplets" /></div>
- </div>
- <div class="leftsideright">
- <div id="fourthcolumn"><img class= "fourth" src="lightDrops.png" alt="Water droplets" /></div>
- <div id="fifthcolumn"><img class= "fifth" src="darkDrops.png" alt="Water droplets" /></div>
- </div>
- </div>
- <div id="rightside">
- <div class="leftsideleft">
- <div class="leftcolumn">
- <div id="sixthcolumn"><img class= "sixth" src="lightDrops.png" alt="Water droplets" /></div>
- <div id="seventhcolumn"><img class= "seventh" src="darkDrops.png" alt="Water droplets" /></div>
- </div>
- <div id="eighthcolumn"><img class= "eighth" src="lightDrops.png" alt="Water droplets" /></div>
- </div>
- <div class="leftsideright">
- <div id="ninthcolumn"><img class= "ninth" src="darkDrops.png" alt="Water droplets" /></div>
- <div id="tenthcolumn"><img class= "tenth" src="lightDrops.png" alt="Water droplets" /></div>
- </div>
- </div>
- </div>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment