Location: PHPKode > scripts > PHP Show Processes > show_processes.php
<?php

######
### start of user configuration
######

## mysql username
$mysql_username = "usergoeshere";
## mysql password
$mysql_password = "passgoeshere";
## mysql host
$mysql_host = "localhost";

## leave at 0 if you don't want it to refresh.. default is 20
$refreshTime = 20;

######
### end of user configuration
######


if($refreshTime > 0){
   print "<meta http-equiv='refresh' content='$refreshTime'>";
}

$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
$result = mysql_list_processes($link);

print "
<style>
body {
  background: #eaeaea;
}

td, th {
   background: #ffffff;
   font-family: arial;
   font-size: 11px;
}

.killed td {
   background: pink;
}

</style>
<table cellpadding='5' cellspacing='0' border='0'>
<tr>
<th>ID</th>
<th>HOST</th>
<th>USER</th>
<th>DB</th>
<th>COMMAND</th>
<th>STATE</th>
<th>TIME</th>
<th>INFO</th>
</tr>
";

while ($row = mysql_fetch_assoc($result)){

   if($row[Time] > 100){
      $class = " class='killed'";
   }else{
      $class = "";
   }
   print "
   <tr".$class.">
   <td>$row[Id]</td>
   <td>$row[Host]</td>
   <td>$row[User]</td>
   <td>$row[db]</td>
   <td>$row[Command]</td>
   <td>$row[State]</td>
   <td>$row[Time]</td>
   <td>$row[Info]</td>
   </tr>
   ";
   
   foreach($row as $k=>$v){
      $row[$k] = htmlentities($v, ENT_QUOTES);
   }

}

print "</table>";

?>
Return current item: PHP Show Processes