Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.42 KB | None | 0 0
  1.  
  2.  
  3.  
  4.           <h2>40 Day Preview</h2>
  5.           <div class="table-responsive">
  6.             <table class="table table-striped table-sm">
  7.               <thead>
  8.  
  9.                 <tr>
  10.                   <th>Days from Today</th>
  11.                   <th>Avrage Wave Height</th>
  12.                   <th>Star Rating</th>
  13.                   <th>Wave Intervals</th>
  14.                   <th>Tempreture</th>
  15.                   <th>Weather</th>
  16.                   <th>More Information</th>
  17.  
  18.                 </tr>
  19.               </thead>
  20.                   <tbody>
  21. <?php
  22.  
  23.   include 'api.php';
  24.  
  25.  
  26.     //set up date array to pull in todays day          
  27.     $dates = array("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
  28.     //Set date as day
  29.     $currentDay = date ('l'); // (lowercase 'L')
  30.            
  31.     $dayFromNow = 0;
  32.  
  33.  
  34.  
  35.     $moreInfoModal = 0;
  36.  
  37.  
  38. $primarySwell = "Primary Swell";
  39. $secondarySwell = "Secondary Swell";
  40. $tertiarySwell = "Tertiary Swell";
  41.  
  42.  
  43.  
  44.  
  45.     foreach ($data as $record) {
  46. $weatherCondition = "{$record['condition']['weather']}";
  47.         $solidStar = "{$record['solidRating']}";
  48.         $fadedStar = "{$record['fadedRating']}";
  49.         $StarRateFloat = 0;
  50.  
  51.             echo "<tr>";
  52.                          echo "<td>";  
  53.            
  54.                                  if($dayFromNow == 0){
  55.                                         echo "$currentDay";
  56.                                     }
  57.                                     else{
  58.                                         echo "Days from now $dayFromNow";
  59.                                     }  
  60.  
  61.                         echo "</td>";
  62.                                 echo "<td> {$record['swell']['components']['combined']['height']}</td>";
  63.                        
  64.                         echo "<td>";
  65.                                 while ($StarRateFloat < $solidStar){
  66.                                     echo "&#9733;" ;
  67.                                     $StarRateFloat++;
  68.                                 }
  69.  
  70.                                 $StarRateFloat = 0;
  71.  
  72.                                 while ($StarRateFloat < $fadedStar){
  73.                                     echo " &#9734;";
  74.                                     $StarRateFloat++;
  75.                                 }
  76.  
  77.                         echo "</td>";
  78.                         echo "<td> {$record['swell']['components']['combined']['period']}</td>";
  79.                         echo "<td> {$record['condition']['temperature']}</td>";
  80. ?>
  81.     <td> <img src="http://cdnimages.magicseaweed.com/30x30/<?php echo $weatherCondition;?>.png" alt=""> </td>
  82.  
  83.                         <td>
  84.                             <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal<?php echo $moreInfoModal;?>">
  85.                             Full Day
  86.                             </button>
  87.  
  88.  
  89.                         </td>
  90. <?php
  91.        
  92.              
  93.             echo "</tr>";
  94.  
  95. ?>
  96.             <!-- Modal -->
  97.                     <div class="modal fade" id="modal<?php echo $moreInfoModal;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  98.                       <div class="modal-dialog" role="document">
  99.                         <div class="modal-content">
  100.                           <div class="modal-header">
  101.                             <h5 class="modal-title" id="exampleModalLabel">
  102. <?php
  103.                                                      if($dayFromNow == 0){
  104.                                                             echo "$currentDay";
  105.                                                         }
  106.                                                         else{
  107.                                                             echo "Days from now $dayFromNow";
  108.                                                         }
  109. ?> 
  110.                             </h5>
  111.                             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  112.                               <span aria-hidden="true">&times;</span>
  113.                             </button>
  114.                           </div>
  115.                           <div class="modal-body">
  116.                              
  117.                                
  118.  
  119.  
  120.         <?php          
  121.  
  122.         // echo $primarySwell $secondarySwell $tertiarySwell;
  123. echo "<div class='text-center'>";
  124.  
  125. echo "<h3> Genral rating </h3>";
  126.                 $solidStar = "{$record['solidRating']}";
  127.         $fadedStar = "{$record['fadedRating']}";
  128.                                 while ($StarRateFloat < $solidStar){
  129.                                     echo "&#9733;" ;
  130.                                     $StarRateFloat++;
  131.                                 }
  132.  
  133.                                 $StarRateFloat = 0;
  134.  
  135.                                 while ($StarRateFloat < $fadedStar){
  136.                                     echo " &#9734;";
  137.                                     $StarRateFloat++;
  138.                                 }
  139.             echo "<hr>";
  140.  
  141.             echo "Wind speed: {$record['wind']['speed']}<br />";
  142.             echo "Temperature: {$record['condition']['temperature']}<br />";
  143.             echo "minBreakingHeight: {$record['swell']['minBreakingHeight']}<br />";
  144.             echo "absMinBreakingHeight: {$record['swell']['absMinBreakingHeight']}<br />";
  145.             echo "maxBreakingHeight: {$record['swell']['maxBreakingHeight']}<br />";
  146.             echo "absMaxBreakingHeight: {$record['swell']['absMaxBreakingHeight']}<br />";
  147.             echo "<hr>";
  148.  
  149.             echo "<h3> Components </h3>";
  150.             echo "height: {$record['swell']['components']['combined']['height']}<br />";
  151.             echo "period: {$record['swell']['components']['combined']['period']}<br />";
  152.             echo "direction: {$record['swell']['components']['combined']['direction']}<br />";
  153.             echo "compassDirection: {$record['swell']['components']['combined']['compassDirection']}<br />";
  154.             echo "<hr>";
  155.  
  156.             echo "<h3> Primary Swell </h3>";
  157.             echo "height: {$record['swell']['components']['primary']['height']}<br />";
  158.             echo "period: {$record['swell']['components']['primary']['period']}<br />";
  159.             echo "direction: {$record['swell']['components']['primary']['direction']}<br />";
  160.             echo "compassDirection: {$record['swell']['components']['primary']['compassDirection']}<br />";
  161.             echo "<hr>";
  162.  
  163.             echo "<h3> Secondary Swell </h3>";
  164.             echo "height: {$record['swell']['components']['secondary']['height']}<br />";
  165.             echo "period: {$record['swell']['components']['secondary']['period']}<br />";
  166.             echo "direction: {$record['swell']['components']['secondary']['direction']}<br />";
  167.             echo "compassDirection: {$record['swell']['components']['secondary']['compassDirection']}<br />";
  168.             echo "<hr>";
  169.  
  170.             echo "<h3> Swell Tertiary </h3>";
  171.             echo "height: {$record['swell']['components']['tertiary']['height']}<br />";
  172.             echo "period: {$record['swell']['components']['tertiary']['period']}<br />";
  173.             echo "direction: {$record['swell']['components']['tertiary']['direction']}<br />";
  174.             echo "compassDirection: {$record['swell']['components']['tertiary']['compassDirection']}<br />";
  175.             echo "<hr>";
  176.  
  177.             echo "<h3> Wind </h3>";
  178.             echo "speed: {$record['wind']['speed']}<br />";
  179.             echo "direction: {$record['wind']['direction']}<br />";
  180.             echo "compassDirection: {$record['wind']['compassDirection']}<br />";
  181.             echo "chill: {$record['wind']['chill']}<br />";
  182.             echo "gusts: {$record['wind']['gusts']}<br />";
  183.             echo "unit: {$record['wind']['unit']}<br />";
  184.             echo "<hr>";
  185.  
  186.             echo "<h3> Condition </h3>";
  187.             echo "pressure: {$record['condition']['pressure']}<br />";
  188.             echo "temperature: {$record['condition']['temperature']}<br />";
  189.             echo "unitPressure: {$record['condition']['unitPressure']}<br />";
  190.             echo "unit: {$record['condition']['unit']}<br />";
  191.             echo "<hr>";
  192.  
  193.  
  194.         echo "<h3> Condition </h3>";
  195.             $swellGif = "{$record['charts']['swell']}";  
  196.             echo "<img class='img-fluid' src='$swellGif'>";
  197.         echo "<h3> Wind </h3>";
  198.  
  199.             $windGif = "{$record['charts']['wind']}";  
  200.             echo "<img class='img-fluid' src='$windGif'>";
  201.         echo "<h3> Pressure </h3>";
  202.  
  203.             $pressureGif = "{$record['charts']['pressure']}";  
  204.             echo "<img class='img-fluid' src='$pressureGif'>";
  205.             $sstGif = "{$record['charts']['sst']}";
  206.  
  207.         if(strlen($sstGif) > 1){
  208.             echo "<h3> Sst </h3>";
  209.             echo "<img class='img-fluid' src='$sstGif'>";
  210.  
  211.         }
  212.    
  213.  
  214. echo '</div>';
  215.                        ?>
  216.  
  217.                           </div>
  218.                           <div class="modal-footer">
  219.                             <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  220.                           </div>
  221.                         </div>
  222.                       </div>
  223.                     </div>
  224. <?php
  225.         //unique-ish id for each modal
  226.         $moreInfoModal++;
  227.         //Count over the next day
  228.         $dayFromNow++;
  229.     }
  230.  
  231. ?>
  232.  
  233. <!-- Large modal -->
  234.  
  235.         </tbody>
  236.          
  237.        
  238.             </table>
  239.            
  240.           </div>
  241.  
  242. <!-- Button trigger modal -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement