Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. $header = null;
  2. $pcs = array();
  3. if (($handle = fopen($filename, 'rb')) !== false) { // opening using rb is binary safe, not necessary just safer in this multi-byte emoji world
  4. while (($row = fgetcsv($handle)) !== false ) { // don't need to define the length of delimiter if you're just on the defaults
  5. // just a quick way to skip over the header row
  6. if (is_null($header)) {
  7. $header = $row;
  8. continue; // continue will skip the rest of the logic in this loop iteration, but not break out of the loop
  9. }
  10. list($ip, $side, $pos) = $row; // get the first three values from the $row array and assign them to variables
  11. // print_r($row);
  12. // $ip = $row[0];
  13. // $side = $row[1];
  14. // $pos = $row[2];
  15. if (empty($side)) { // empty checks for null, 0 or empty string values
  16. continue;
  17. }
  18.  
  19. $pcs[$ip] = $ip; // and then assign them into an associative array, using the array key as the code and the value as the name
  20. $pcs[$pos] = $pos; // and then assign them into an associative array, using the array key as the code and the value as the name
  21. $pcs[$side] = $side;
  22.  
  23. print_r($pcs);
  24. }
  25.  
  26. fclose($handle);
  27. }
  28.  
  29. <table
  30. style="width: 40%; text-align: left; margin-left: auto; margin-right: auto;"
  31. border="0" cellpadding="2" cellspacing="2" class="inlineTable">
  32. <tbody>
  33. <tr>
  34. <td style="text-align: center;"><strong style="font-size: 40px; font-family:verdana;"><font color="#0000FF">REBOOT</font></td>
  35. <td style="text-align: center;"><strong style="font-size: 40px; font-family:verdana;"><font color="#0000FF">ABORT</font></td>
  36. <?= $row ?>
  37.  
  38. </tr>
  39.  
  40. <!-- iterate over the $teams array, in each loop assign the current element to the $team variable -->
  41. <?php foreach ($pcs as $ip=>$side): ?>
  42. <tr>
  43. <td style="text-align: center;"> <!-- without using js, you'll need to have a separate form for each button, so only one $_POST variable is sent per button press -->
  44. <form method="POST">
  45. <!-- use a hidden form element to pass the team code across, using the same $_POST value -->
  46. <input type="hidden" name="pc" value="<?= $ip ?> -r" />
  47. <button type="submit" style="height:60px;width:250px;background-color:red">
  48. <b>***** REBOOT *****<br> <?= $ip ?> <br> Position: <?= $side ?> </b></style>
  49. </button>
  50. </form>
  51. </td>
  52. <td style="text-align: center;">
  53. <form method="POST">
  54. <input type="hidden" name="pc" value="<?= $ip ?> -a" />
  55. <button type="submit" style="height:60px;width:250px;background-color:green">
  56. <b>ABORT REBOOT<br> <?= $ip ?> <br> Position: <?= $side ?> </b></style>
  57. </button>
  58. </form>
  59. </td>
  60. </tr>
  61. <?php endforeach; ?>
  62.  
  63. </tbody>
  64. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement