Advertisement
Izya12

Untitled

Mar 7th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <meta http-equiv='refresh' content='1;url=<?php echo "31.php"; ?>'>
  2. <?php
  3.  
  4.  
  5. define('DB_HOST', 'localhost'); // сервер БД
  6. define('DB_USER', 'root'); // логин БД
  7. define('DB_PASS', '121788'); // пароль БД
  8. define('DB_NAME', 'syslog'); // имя БД
  9.  
  10. // подключаемся к БД
  11. mysql_connect(DB_HOST,DB_USER,DB_PASS);
  12. mysql_select_db(DB_NAME);
  13.  
  14. // делаем запрос к БД
  15. $result = mysql_query("SELECT * FROM logs ORDER BY id DESC LIMIT 20");
  16.  
  17. // количество строк
  18. $num_results = mysql_num_rows($result);
  19. echo '<table cellpadding="5" cellspacing="0" border="1" width="1500">';
  20.  
  21. // Постоянное обновление страници
  22.  
  23. // начальный цвет
  24. $color = '#808080';
  25. for ($i = 0; $i<$num_results; $i++) {
  26.     $row = mysql_fetch_array($result);
  27.  
  28.     // начало строки
  29.     echo '<tr ';
  30.  
  31.     // определяем какой цвет выводить
  32.     if ($color=='#808080') $color = '#ffffff';
  33.     else $color = '#808080';
  34.  
  35.     // выводим цвет строки и данные таблицы
  36.     echo 'bgcolor="' . $color . '"><td width="20">' .
  37.     stripslashes($row["host"]) . '</td>';
  38.     echo '<td width="120">' .
  39.     stripslashes($row["msg"]) . '</td>';
  40.     echo '<td width="60">' .
  41.     stripslashes($row["datetime"]) . '</td>';
  42.     echo '</tr>';
  43. }
  44. echo '</table>';
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement