Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $header = null;
- $pcs = array();
- if (($handle = fopen($filename, 'rb')) !== false) { // opening using rb is binary safe, not necessary just safer in this multi-byte emoji world
- while (($row = fgetcsv($handle)) !== false ) { // don't need to define the length of delimiter if you're just on the defaults
- // just a quick way to skip over the header row
- if (is_null($header)) {
- $header = $row;
- continue; // continue will skip the rest of the logic in this loop iteration, but not break out of the loop
- }
- list($ip, $side, $pos) = $row; // get the first three values from the $row array and assign them to variables
- // print_r($row);
- // $ip = $row[0];
- // $side = $row[1];
- // $pos = $row[2];
- if (empty($side)) { // empty checks for null, 0 or empty string values
- continue;
- }
- $pcs[$ip] = $ip; // and then assign them into an associative array, using the array key as the code and the value as the name
- $pcs[$pos] = $pos; // and then assign them into an associative array, using the array key as the code and the value as the name
- $pcs[$side] = $side;
- print_r($pcs);
- }
- fclose($handle);
- }
- <table
- style="width: 40%; text-align: left; margin-left: auto; margin-right: auto;"
- border="0" cellpadding="2" cellspacing="2" class="inlineTable">
- <tbody>
- <tr>
- <td style="text-align: center;"><strong style="font-size: 40px; font-family:verdana;"><font color="#0000FF">REBOOT</font></td>
- <td style="text-align: center;"><strong style="font-size: 40px; font-family:verdana;"><font color="#0000FF">ABORT</font></td>
- <?= $row ?>
- </tr>
- <!-- iterate over the $teams array, in each loop assign the current element to the $team variable -->
- <?php foreach ($pcs as $ip=>$side): ?>
- <tr>
- <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 -->
- <form method="POST">
- <!-- use a hidden form element to pass the team code across, using the same $_POST value -->
- <input type="hidden" name="pc" value="<?= $ip ?> -r" />
- <button type="submit" style="height:60px;width:250px;background-color:red">
- <b>***** REBOOT *****<br> <?= $ip ?> <br> Position: <?= $side ?> </b></style>
- </button>
- </form>
- </td>
- <td style="text-align: center;">
- <form method="POST">
- <input type="hidden" name="pc" value="<?= $ip ?> -a" />
- <button type="submit" style="height:60px;width:250px;background-color:green">
- <b>ABORT REBOOT<br> <?= $ip ?> <br> Position: <?= $side ?> </b></style>
- </button>
- </form>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement