fj1200 Posted November 11, 2008 Share Posted November 11, 2008 I'm trying to modify an existing and very useful and important app I wrote a year ago that checks the presence of several servers around the country and verifies ftp is running on each every 2 minutes. Results are displayed on a php page - if a server does down the row goes red and sends the IT guys at the site and me an email. Ok if you're sitting in front of the monitor, but I want a graphical version for display on a large screen. I want to display large 2 icons in each table cell, one for a ping response and one for ftp status. for both, a value of '0' is live, '1' is down. For ftp I'm using ncftpput as it's exit codes are well documented and I can display the reason on screen. How do I get the results into columns - say - 3 servers for one site, 4 for a 2nd and 3rd, and 2 for a 4th site so it's consistent and easy to follow? Been hurting my head on it all morning! I'm ok with php but this is challenging me a touch. I want something like: EXTERNAL SERVERS | INTERNAL SERVERS SITE 1 | SITE 2 | SITE 3 | SITE 4 x x x x x x x x x x x x x x x x x x x x x x x x x x Where X is a graphic of a light. Pretty - but it works very well and is highly visible. I eventually want an audible warning when 2 of the external servers go down. Each X is a different server, in 2 groups at 4 sites. At the moment, it works but I get one whole row of icons for each server. Pages of them! AArrgghh! Any ideas? There's probably a simple way of doing it but I can't see it! <EDIT> Is there a way to make a row or icon flash? refresh the colour every 2 seconds or something? Quote Link to comment https://forums.phpfreaks.com/topic/132278-database-query-results-in-a-4-x-4-grid-instead-of-rows/ Share on other sites More sharing options...
Garethp Posted November 11, 2008 Share Posted November 11, 2008 You want something like $i = 0; //query echo "<table> <tr> <td colspan=2> External Servers </td> <td colspan=2> Internal </td> </tr> <tr> <td> Site1 </td> <td> Site 2 </td> <td> Site3 </td> <td> Site 4 </td> </tr> "; while($row=mysql_fetch_array(query)) { echo "<td>" . $row['x'] . "</td>"; if($i == 4) { echo "</tr><tr>"; $i = 0; } else { $i ++; } } echo "</tr></table>"; Well you get the general idea. Try it. Change the $i setting if you're getting the wrong amount of cols Quote Link to comment https://forums.phpfreaks.com/topic/132278-database-query-results-in-a-4-x-4-grid-instead-of-rows/#findComment-687708 Share on other sites More sharing options...
trq Posted November 11, 2008 Share Posted November 11, 2008 Did you check out the FAQ / Snippet repository ? Quote Link to comment https://forums.phpfreaks.com/topic/132278-database-query-results-in-a-4-x-4-grid-instead-of-rows/#findComment-687709 Share on other sites More sharing options...
radalin Posted November 11, 2008 Share Posted November 11, 2008 you should check jquery, prototype(scriptacoulous) or dojo for this kind of flashing icons and effects. I guess you have to use double loops something like this may help you: for ($i = 0 ;$i < count($server_list); $i++) { echo '<tr>'; for ($j = 0 ; $j < 4; $j++) { //Instead of 4 put max col number for a row. if ($server_list[$i+$j+1]) { echo '<td>' . $server_list[$i+$j] . '</td>'; } else { //If the next one does not exists put a col with left of col number echo '<td colspan="' . 4 - $j . '"'>; } } echo '</tr>'; } Something like this might help you I guess. Quote Link to comment https://forums.phpfreaks.com/topic/132278-database-query-results-in-a-4-x-4-grid-instead-of-rows/#findComment-687715 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.