Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Co drugi temat inny kolor forum
Forum PHP.pl > Forum > PHP
Diego12
Witam chcę wykonać takie coś jak mamy panel ostatnie tematy na forum to chciałbym aby nagłówek(Temat,Wyświetleń,Odpowiedzi,Ostatni post)oraz (Moje ostatnie tematy :: Moje ostatnie posty :: Nowe posty :: Moje obserwowane tematy) były na kolor czarny a tematy wewnątrz panelu na przemian czarny- szary . Mógłby mi ktoś pomóc z wykonaniem niżej daje kod forum_threads_list_panel.php :
Kod
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: forum_threads_list_panel.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }

global $lastvisited;

if (!isset($lastvisited) || !isnum($lastvisited)) { $lastvisited = time(); }

$data = dbarray(dbquery(
    "SELECT tt.thread_lastpost
    FROM ".DB_FORUMS." tf
    INNER JOIN ".DB_THREADS." tt ON tf.forum_id = tt.forum_id
    WHERE ".groupaccess('tf.forum_access')." AND thread_hidden='0'
    ORDER BY tt.thread_lastpost DESC LIMIT ".($settings['numofthreads']-1).", ".$settings['numofthreads']
));

$timeframe = empty($data['thread_lastpost']) ? 0 : $data['thread_lastpost'];

$result = dbquery(
    "SELECT tt.thread_id, tt.thread_subject, tt.thread_views, tt.thread_lastuser, tt.thread_lastpost,
    tt.thread_poll, tf.forum_id, tf.forum_name, tf.forum_access, tt.thread_lastpostid, tt.thread_postcount, tu.user_id, tu.user_name,
    tu.user_status
    FROM ".DB_THREADS." tt
    INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
    INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
    WHERE ".groupaccess('tf.forum_access')." AND tt.thread_lastpost >= ".$timeframe." AND tt.thread_hidden='0'
    ORDER BY tt.thread_lastpost DESC LIMIT 0,".$settings['numofthreads']
);

if (dbrows($result)) {
    $i = 0;
    opentable($locale['global_040']);
    echo "<table bgcolor='#414141' cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
    echo "<td class='tbl2'> </td>\n";
    echo "<td width='100%' class='tbl2'><strong>".$locale['global_044']."</strong></td>\n";
    echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_045']."</strong></td>\n";
    echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_046']."</strong></td>\n";
    echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_047']."</strong></td>\n";
    echo "</tr>\n";
    while ($data = dbarray($result)) {
        $row_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
        echo "<tr>\n<td class='".$row_color."'>";
        if ($data['thread_lastpost'] > $lastvisited) {
            $thread_match = $data['thread_id']."\|".$data['thread_lastpost']."\|".$data['forum_id'];
            if (iMEMBER && ($data['thread_lastuser'] == $userdata['user_id'] || preg_match("(^\.{$thread_match}$|\.{$thread_match}\.|\.{$thread_match}$)", $userdata['user_threads']))) {
                echo "<img src='".get_image("folder")."' alt='' />";
            } else {
                echo "<img src='".get_image("foldernew")."' alt='' />";
            }
        } else {
            echo "<img src='".get_image("folder")."' alt='' />";
        }
        if ($data['thread_poll']) {
            $thread_poll = "<span class='small' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
        } else {
            $thread_poll = "";
        }
        echo "</td>\n";
        echo "<td width='100%' class='".$row_color."'>".$thread_poll."<a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."&pid=".$data['thread_lastpostid']."#post_".$data['thread_lastpostid']."' title='".$data['thread_subject']."'>".trimlink($data['thread_subject'], 30)."</a><br />\n".$data['forum_name']."</td>\n";
        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".($data['thread_postcount']-1)."</td>\n";
        echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".profile_link($data['thread_lastuser'], $data['user_name'], $data['user_status'])."<br />\n".showdate("forumdate", $data['thread_lastpost'])."</td>\n";
        echo "</tr>\n";
        $i++;
    }
    echo "</table>\n";
    if (iMEMBER) {
        echo "<div class='tbl1' style='text-align:center'><a href='".INFUSIONS."forum_threads_list_panel/my_threads.php'>".$locale['global_041']."</a> ::\n";
        echo "<a href='".INFUSIONS."forum_threads_list_panel/my_posts.php'>".$locale['global_042']."</a> ::\n";
        echo "<a href='".INFUSIONS."forum_threads_list_panel/new_posts.php'>".$locale['global_043']."</a>";
        if($settings['thread_notify']) {
            echo " ::\n<a href='".INFUSIONS."forum_threads_list_panel/my_tracked_threads.php'>".$locale['global_056']."</a>";
        }
        echo "</div>\n";
    }
    closetable();
}
?>


chodzi mi o tło oczywiście smile.gif
toaspzoo
prosty przykład:

  1. for($i=0;$i<10;$i++)
  2. {
  3.  
  4. if($i%2==0) { echo '<font color=green>ziel kategoria'.$i.'</font>';
  5.  
  6. }else
  7. {
  8. ($i%2==0) { echo '<font color=red> czerw kategoria'.$i.'</font>';}
  9.  
  10.  
  11. }


Po prostu, jeżeli reszta z dzielenia $i/2 == 0, to daje kolor dzielony, tzw. modulo
Diego12
i to mam gdzie wkleić ?
sorki ale zielony jestem biggrin.gif pzdr
toaspzoo
Masz zastosować to do twojego kodu, np:
  1. // $row_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
  2. ////////////////////////////
  3. if($i%2==0) { $row_color = 'tbl1'} else { $row_color = 'tbl2'; }
  4. //////////////////////////////
  5.  
  6.  
  7. // tego nie zmieniaj (zostaw)
  8. echo "<tr>\n<td class='".$row_color."'>";
  9.  
  10.  

znajdź to, co zakomentowałem ( //... ) i zamień,
masz to zaraz po while...

Mam dobry dzień, masz tutaj kod

  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2011 Nick Jones
  5. | <a href="http://www.php-fusion.co.uk/" target="_blank">http://www.php-fusion.co.uk/</a>
  6. +--------------------------------------------------------+
  7. | Filename: forum_threads_list_panel.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. if (!defined("IN_FUSION")) { die("Access Denied"); }
  19.  
  20. global $lastvisited;
  21.  
  22. if (!isset($lastvisited) || !isnum($lastvisited)) { $lastvisited = time(); }
  23.  
  24. $data = dbarray(dbquery(
  25. "SELECT tt.thread_lastpost
  26. FROM ".DB_FORUMS." tf
  27. INNER JOIN ".DB_THREADS." tt ON tf.forum_id = tt.forum_id
  28. WHERE ".groupaccess('tf.forum_access')." AND thread_hidden='0'
  29. ORDER BY tt.thread_lastpost DESC LIMIT ".($settings['numofthreads']-1).", ".$settings['numofthreads']
  30. ));
  31.  
  32. $timeframe = empty($data['thread_lastpost']) ? 0 : $data['thread_lastpost'];
  33.  
  34. $result = dbquery(
  35. "SELECT tt.thread_id, tt.thread_subject, tt.thread_views, tt.thread_lastuser, tt.thread_lastpost,
  36. tt.thread_poll, tf.forum_id, tf.forum_name, tf.forum_access, tt.thread_lastpostid, tt.thread_postcount, tu.user_id, tu.user_name,
  37. tu.user_status
  38. FROM ".DB_THREADS." tt
  39. INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
  40. INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
  41. WHERE ".groupaccess('tf.forum_access')." AND tt.thread_lastpost >= ".$timeframe." AND tt.thread_hidden='0'
  42. ORDER BY tt.thread_lastpost DESC LIMIT 0,".$settings['numofthreads']
  43. );
  44.  
  45. if (dbrows($result)) {
  46.  
  47. opentable($locale['global_040']);
  48. echo "<table bgcolor='#414141' cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
  49. echo "<td class='tbl2'> </td>\n";
  50. echo "<td width='100%' class='tbl2'><strong>".$locale['global_044']."</strong></td>\n";
  51. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_045']."</strong></td>\n";
  52. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_046']."</strong></td>\n";
  53. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_047']."</strong></td>\n";
  54. echo "</tr>\n";
  55. while ($data = dbarray($result)) {
  56.  
  57. if($i%2==0) { $row_color = 'tbl1'} else { $row_color = 'tbl2'; }
  58. $i++;
  59. echo "<tr>\n<td class='".$row_color."'>";
  60. if ($data['thread_lastpost'] > $lastvisited) {
  61. $thread_match = $data['thread_id']."\|".$data['thread_lastpost']."\|".$data['forum_id'];
  62. if (iMEMBER && ($data['thread_lastuser'] == $userdata['user_id'] || preg_match("(^\.{$thread_match}$|\.{$thread_match}\.|\.{$thread_match}$)", $userdata['user_threads']))) {
  63. echo "<img src='".get_image("folder")."' alt='' />";
  64. } else {
  65. echo "<img src='".get_image("foldernew")."' alt='' />";
  66. }
  67. } else {
  68. echo "<img src='".get_image("folder")."' alt='' />";
  69. }
  70. if ($data['thread_poll']) {
  71. $thread_poll = "<span class='small' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
  72. } else {
  73. $thread_poll = "";
  74. }
  75. echo "</td>\n";
  76. echo "<td width='100%' class='".$row_color."'>".$thread_poll."<a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."&pid=".$data['thread_lastpostid']."#post_".$data['thread_lastpostid']."' title='".$data['thread_subject']."'>".trimlink($data['thread_subject'], 30)."</a><br />\n".$data['forum_name']."</td>\n";
  77. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
  78. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".($data['thread_postcount']-1)."</td>\n";
  79. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".profile_link($data['thread_lastuser'], $data['user_name'], $data['user_status'])."<br />\n".showdate("forumdate", $data['thread_lastpost'])."</td>\n";
  80. echo "</tr>\n";
  81. $i++;
  82. }
  83. echo "</table>\n";
  84. if (iMEMBER) {
  85. echo "<div class='tbl1' style='text-align:center'><a href='".INFUSIONS."forum_threads_list_panel/my_threads.php'>".$locale['global_041']."</a> ::\n";
  86. echo "<a href='".INFUSIONS."forum_threads_list_panel/my_posts.php'>".$locale['global_042']."</a> ::\n";
  87. echo "<a href='".INFUSIONS."forum_threads_list_panel/new_posts.php'>".$locale['global_043']."</a>";
  88. if($settings['thread_notify']) {
  89. echo " ::\n<a href='".INFUSIONS."forum_threads_list_panel/my_tracked_threads.php'>".$locale['global_056']."</a>";
  90. }
  91. echo "</div>\n";
  92. }
  93. closetable();
  94. }
  95. ?>
Diego12
Dzięki za kod i poświęcony czas tylko nie wiem czemu taki błąd jest :
Kod
Parse error: syntax error, unexpected '}' in /home/ligarf/public_html/infusions/forum_threads_list_panel/forum_threads_list_panel.php on line 57

i rozwala stronę
Necsord
  1. if($i%2==0) { $row_color = 'tbl1' } else { $row_color = 'tbl2'; }


  1. if($i%2==0) { $row_color = 'tbl1'; } else { $row_color = 'tbl2'; }


Średnik.
Diego12
Nadal nie ma tła tak mam zdefiniowane w styles thema :
Kod
  .tbl1 {
    /* background-color: #1b234a; */
    color: #000;
    font-size: 12px;
    padding: 4px;
    }
    .tbl2 {
    /* background-color: #000000; */
    color: #000;
    font-size: 12px;
    padding: 4px;
    }
toaspzoo
  1. .tbl1 {
  2. background-color: #1b234a;
  3. color: #000;
  4. font-size: 12px;
  5. padding: 4px;
  6. }
  7. .tbl2 {
  8. background-color: #000000;
  9. color: #000;
  10. font-size: 12px;
  11. padding: 4px;
  12. }
  13.  


Wgraj to powyżej i sprawdź
Necsord
Przecież masz zakomentowany background-color w obydwu klasach.

down @toaspzoo:
Cytat
41 minut temu

Cytat
40 minut temu

Lubisz się czepiać, co?
toaspzoo
Cytat(Necsord @ 26.11.2011, 15:17:26 ) *
Przecież masz zakomentowany background-color w obydwu klasach.


Przecież mu to poprawiłem, po co więc to piszesz?
Diego12
Panowie działa smile.gif
Lecz tematy wszystkie są czarne nie ma na przemian a ja chciałbym tak :
tam gdzie temat wyświetl odwiedź... ma być kolor czarny na dole moje ostatnie tematy.... kolor też czarny w środku na przemian czarny - szary tak jest obecnie :
Tak jest obecnie :
klik
a ja chciałbym aby było tak :
klik
Pozdrawiam
toaspzoo
  1. <?php
  2. /*-------------------------------------------------------+
  3.   | PHP-Fusion Content Management System
  4.   | Copyright (C) 2002 - 2011 Nick Jones
  5.   | <a href="http://www.php-fusion.co.uk/" target="_blank">http://www.php-fusion.co.uk/</a>
  6.   +--------------------------------------------------------+
  7.   | Filename: forum_threads_list_panel.php
  8.   | Author: Nick Jones (Digitanium)
  9.   +--------------------------------------------------------+
  10.   | This program is released as free software under the
  11.   | Affero GPL license. You can redistribute it and/or
  12.   | modify it under the terms of this license which you
  13.   | can read by viewing the included agpl.txt or online
  14.   | at www.gnu.org/licenses/agpl.html. Removal of this
  15.   | copyright header is strictly prohibited without
  16.   | written permission from the original author(s).
  17.   +--------------------------------------------------------*/
  18. if (!defined("IN_FUSION")) { die("Access Denied"); }
  19.  
  20. global $lastvisited;
  21.  
  22. if (!isset($lastvisited) || !isnum($lastvisited)) { $lastvisited = time(); }
  23.  
  24. $data = dbarray(dbquery(
  25. "SELECT tt.thread_lastpost
  26. FROM ".DB_FORUMS." tf
  27. INNER JOIN ".DB_THREADS." tt ON tf.forum_id = tt.forum_id
  28. WHERE ".groupaccess('tf.forum_access')." AND thread_hidden='0'
  29. ORDER BY tt.thread_lastpost DESC LIMIT ".($settings['numofthreads']-1).", ".$settings['numofthreads']
  30. ));
  31.  
  32. $timeframe = empty($data['thread_lastpost']) ? 0 : $data['thread_lastpost'];
  33.  
  34. $result = dbquery(
  35. "SELECT tt.thread_id, tt.thread_subject, tt.thread_views, tt.thread_lastuser, tt.thread_lastpost,
  36. tt.thread_poll, tf.forum_id, tf.forum_name, tf.forum_access, tt.thread_lastpostid, tt.thread_postcount, tu.user_id, tu.user_name,
  37. tu.user_status
  38. FROM ".DB_THREADS." tt
  39. INNER JOIN ".DB_FORUMS." tf ON tt.forum_id=tf.forum_id
  40. INNER JOIN ".DB_USERS." tu ON tt.thread_lastuser=tu.user_id
  41. WHERE ".groupaccess('tf.forum_access')." AND tt.thread_lastpost >= ".$timeframe." AND tt.thread_hidden='0'
  42. ORDER BY tt.thread_lastpost DESC LIMIT 0,".$settings['numofthreads']
  43. );
  44.  
  45. if (dbrows($result)) {
  46.  
  47. opentable($locale['global_040']);
  48. echo "<table bgcolor='#414141' cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n<tr>\n";
  49. echo "<td class='tbl2'> </td>\n";
  50. echo "<td width='100%' class='tbl2'><strong>".$locale['global_044']."</strong></td>\n";
  51. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_045']."</strong></td>\n";
  52. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_046']."</strong></td>\n";
  53. echo "<td width='1%' class='tbl2' style='text-align:center;white-space:nowrap'><strong>".$locale['global_047']."</strong></td>\n";
  54. echo "</tr>\n";
  55. while ($data = dbarray($result)) {
  56.  
  57. if($i%2==0) { $row_color = 'tbl1'} else { $row_color = 'tbl2'; }
  58.  
  59. echo "<tr>\n<td class='".$row_color."'>";
  60. if ($data['thread_lastpost'] > $lastvisited) {
  61. $thread_match = $data['thread_id']."\|".$data['thread_lastpost']."\|".$data['forum_id'];
  62. if (iMEMBER && ($data['thread_lastuser'] == $userdata['user_id'] || preg_match("(^\.{$thread_match}$|\.{$thread_match}\.|\.{$thread_match}$)", $userdata['user_threads']))) {
  63. echo "<img src='".get_image("folder")."' alt='' />";
  64. } else {
  65. echo "<img src='".get_image("foldernew")."' alt='' />";
  66. }
  67. } else {
  68. echo "<img src='".get_image("folder")."' alt='' />";
  69. }
  70. if ($data['thread_poll']) {
  71. $thread_poll = "<span class='small' style='font-weight:bold'>[".$locale['global_051']."]</span> ";
  72. } else {
  73. $thread_poll = "";
  74. }
  75. echo "</td>\n";
  76. echo "<td width='100%' class='".$row_color."'>".$thread_poll."<a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."&pid=".$data['thread_lastpostid']."#post_".$data['thread_lastpostid']."' title='".$data['thread_subject']."'>".trimlink($data['thread_subject'], 30)."</a><br />\n".$data['forum_name']."</td>\n";
  77. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".$data['thread_views']."</td>\n";
  78. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".($data['thread_postcount']-1)."</td>\n";
  79. echo "<td width='1%' class='".$row_color."' style='text-align:center;white-space:nowrap'>".profile_link($data['thread_lastuser'], $data['user_name'], $data['user_status'])."<br />\n".showdate("forumdate", $data['thread_lastpost'])."</td>\n";
  80. echo "</tr>\n";
  81. $i++;
  82. }
  83. echo "</table>\n";
  84. if (iMEMBER) {
  85. echo "<div class='tbl1' style='text-align:center'><a href='".INFUSIONS."forum_threads_list_panel/my_threads.php'>".$locale['global_041']."</a> ::\n";
  86. echo "<a href='".INFUSIONS."forum_threads_list_panel/my_posts.php'>".$locale['global_042']."</a> ::\n";
  87. echo "<a href='".INFUSIONS."forum_threads_list_panel/new_posts.php'>".$locale['global_043']."</a>";
  88. if($settings['thread_notify']) {
  89. echo " ::\n<a href='".INFUSIONS."forum_threads_list_panel/my_tracked_threads.php'>".$locale['global_056']."</a>";
  90. }
  91. echo "</div>\n";
  92. }
  93. closetable();
  94. }
  95. ?>
  96.  


Spróbuj ten kod
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.