Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CSS][PHP]W jaki sposób bardziej elegancko umieścić CSS w pliku PHP.
Raven1122
post
Post #1





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


Witam, pisze sobie taki plik, który wyświetla błędy w razie problemów na stronie, i mam taki kod:

  1. <?php
  2. header('Content-Type: text/html; charset=utf-8');
  3. require_once("classes/pdo.class.php");
  4. $db = new mysql();
  5. $db->connect();
  6.  
  7. //Getting site language
  8. $stmt = $db->db->prepare("SELECT lang FROM xxx");
  9. $stmt->execute();
  10. $row = $stmt->fetch();
  11. if(is_file("dlang/".$row['lang']."/language.php")){
  12. //Picking languagepack name from DB
  13. //Including Language pack
  14. require_once("/lang/".$row['lang']."/language.php");
  15.  
  16. //Getting client IP
  17. $ip = $_SERVER['REMOTE_ADDR'];
  18. //Checking if IP isn't banned
  19. $stmt = $db->db->prepare("SELECT * FROM xxx WHERE ip = '$ip'");
  20. $stmt->execute();
  21. $count = $stmt->rowCount();
  22. if($count == 0){
  23. //If ip isn't banned
  24. //This way of banning wont work for IP's that changes.
  25. //That's why we will make ban for account too.
  26.  
  27. }
  28. else{
  29. //If ip is banned
  30. echo str_replace("{IP}", $ip, $lang['banneduser']);
  31. }
  32. }
  33. else{
  34. echo "<style type='text/css'>
  35. body{
  36. background:#f2f2f2;
  37. color:#000000;
  38. }
  39. #error{
  40. background:#ffffff;
  41. width:360px;
  42. margin:0 auto;
  43. padding:20px;
  44. }
  45. #errorheader{
  46. background:#e2e2e2;
  47. width:320px;
  48. height:22px;
  49. font-weight:bold;
  50. padding:3px 20px 3px 20px;
  51. margin-bottom:20px;
  52. }
  53.  
  54. </style>";
  55. echo("
  56. <div id='error'>
  57. <div id='errorheader'>Language pack is not installed! <span style='font-size:9px; color:#ff0000; float:right; padding-top:6px; font-family:Tahoma;'>[Issue ID: 1000]</span></div>
  58. There's no ".$row['lang']." language pack installed. Check if <b>".$_SERVER['DOCUMENT_ROOT']."lang/".$row['lang']."/language.php</b> exists. <br /><br /><center><u>For more help visit our forum or wiki.</u></center></div>");
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. ?>


a dokladniej chodzi mi o ta czesc:

  1. else{
  2. echo "<style type='text/css'>
  3. body{
  4. background:#f2f2f2;
  5. color:#000000;
  6. }
  7. #error{
  8. background:#ffffff;
  9. width:360px;
  10. margin:0 auto;
  11. padding:20px;
  12. }
  13. #errorheader{
  14. background:#e2e2e2;
  15. width:320px;
  16. height:22px;
  17. font-weight:bold;
  18. padding:3px 20px 3px 20px;
  19. margin-bottom:20px;
  20. }
  21.  
  22. </style>";
  23. echo("
  24. <div id='error'>
  25. <div id='errorheader'>Language pack is not installed! <span style='font-size:9px; color:#ff0000; float:right; padding-top:6px; font-family:Tahoma;'>[Issue ID: 1000]</span></div>
  26. There's no ".$row['lang']." language pack installed. Check if <b>".$_SERVER['DOCUMENT_ROOT']."lang/".$row['lang']."/language.php</b> exists. <br /><br /><center><u>For more help visit our forum or wiki.</u></center></div>");
  27. }


Jak mozna umiescic ten kod CSS tak, aby ladnie wygladalo i bylo poprawnie wykonane?

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 23:03