• Community Manager

    Strano, mi posti l'altro script?

    🙂


  • Super User
    <?php
       $topicnumber = 10;
       $urlPath = "http://forum.miosito.it";
       $phpbb_root_path = './forum/';
    
       define&#40;'IN_PHPBB', true&#41;;
    
       include&#40;$phpbb_root_path . 'extension.inc'&#41;;
       include&#40;$phpbb_root_path . 'common.'.$phpEx&#41;;
    
       $table_topics = $table_prefix. "topics";
       $table_forums = $table_prefix. "forums";
       $table_posts = $table_prefix. "posts";
       $table_users = $table_prefix. "users";
    
       $query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time
       FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
       WHERE t.topic_id = p.topic_id AND
       f.forum_id = t.forum_id AND
       t.topic_status <> 2 AND
       p.post_id = t.topic_last_post_id AND
       p.poster_id = u.user_id
       ORDER BY p.post_id DESC LIMIT $topicnumber";
       $result = mysql_query&#40;$query&#41; or die&#40;"Query failed"&#41;;
    
       print "";
       while &#40;$row = mysql_fetch_array&#40;$result, MYSQL_ASSOC&#41;&#41;
       &#123;
          echo  "<a href=\"$urlPath/viewtopic.php?topic=$row&#91;topic_id&#93;\"></a>
    <a href=\"$urlPath/viewtopic.php?topic=$row&#91;topic_id&#93;\">" .
          $row&#91;"topic_title"&#93; . 
          "</a>**" .
          $row&#91;"username"&#93; .
          "";
       &#125;
       print "";
    
       mysql_free_result&#40;$result&#41;;
    ?>
    

    Io ho usato questo codice. Teoricamente è sbagliato perché ho cancellato un po' di cose affinché mostri solo il nome del topic ma alcune informazioni le prende lo stesso ma non le fa vedere. Tipo la riga $row["username"] non posso cancellarla e non capisco perché.


  • User Attivo

    Se un topic ha un titolo troppo lungo, come fare a far comparire tre puntini "..." dopo tot lettere ?

    una cosa del genere

    		if &#40;strlen&#40;$topic_title&#41;>27&#41; &#123;
    			$topic_title = substr&#40;$topic_title,0,24&#41; . '...';
    		&#125;
    

    che però non so adattare al mio codice ```
    <?
    $ris_query = "SELECT topic_poster, topic_id, topic_title, username FROM phpbb_topics INNER JOIN phpbb_users ON topic_poster = user_id WHERE forum_id!=10 AND forum_id!=9 ORDER BY topic_time DESC LIMIT 7";
    $db = mysql_connect("xxxxx","xxxxx","xxxxx");
    $res = mysql_db_query("xxxxx",$ris_query) or die('errore');
    $num_righe = mysql_num_rows($res);
    ?>

    <? if($num_righe > 0) { ?>

    <table border="0" cellpadding="0" cellspacing="0">

    <?
    $i = 0;
    while($i < $num_righe) {
    $topic_id = mysql_result($res,$i,"topic_id");
    $topic_title = mysql_result($res,$i,"topic_title");
    $username = mysql_result($res,$i,"username");
    $topic_poster = mysql_result($res,$i,"topic_poster");
    echo "<tr>";
    echo "<td><a href="http://www.tuosito.com/forum/viewtopic.php?t=$topic_id" target="_blank" title="$topic_title" class='link_2'>$topic_title</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>posted by: <a href="http://www.tuosito.com/forum/profile.php?mode=viewprofile&u=$topic_poster" target="_blank" title="$username" class='link_2'>$username</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td></td>";
    echo "</tr>";
    $i++;
    }
    ?>

    </table>

    <? } else echo "Nessun topic presente"; ?>

    
    Grazie !

  • User Attivo

    Vi prego mi aiutate mi manca questa modifica per mettere on line il sito !
    AIUTATEMI PLS !


  • User Attivo

    Basta che le metti subito dopo che assegni la variabile:

    <? 
    $ris_query = "SELECT topic_poster, topic_id, topic_title, username FROM phpbb_topics INNER JOIN phpbb_users ON topic_poster = user_id WHERE forum_id!=10 AND forum_id!=9 ORDER BY topic_time DESC LIMIT 7"; 
    $db = mysql_connect&#40;"xxxxx","xxxxx","xxxxx"&#41;; 
    $res = mysql_db_query&#40;"xxxxx",$ris_query&#41; or die&#40;'errore'&#41;; 
    $num_righe = mysql_num_rows&#40;$res&#41;; 
    ?> 
    
    <? if&#40;$num_righe > 0&#41; &#123; ?> 
    
    <table border="0" cellpadding="0" cellspacing="0"> 
    
    <? 
    $i = 0; 
    while&#40;$i < $num_righe&#41; &#123; 
    $topic_id = mysql_result&#40;$res,$i,"topic_id"&#41;; 
    $topic_title = mysql_result&#40;$res,$i,"topic_title"&#41;; 
    if &#40;strlen&#40;$topic_title&#41;>27&#41;
      $topic_title = substr&#40;$topic_title,0,24&#41; . '...'; 
    $username = mysql_result&#40;$res,$i,"username"&#41;; 
    $topic_poster = mysql_result&#40;$res,$i,"topic_poster"&#41;; 
    echo "<tr>"; 
    echo "<td><a href=\"http://www.tuosito.com/forum/viewtopic.php?t=$topic_id\" target=\"_blank\" title=\"$topic_title\" class='link_2'>$topic_title</td>"; 
    echo "</tr>"; 
    echo "<tr>"; 
    echo "<td>posted by&#58; <a href=\"http&#58;//www.tuosito.com/forum/profile.php?mode=viewprofile&u=$topic_poster\" target=\"_blank\" title=\"$username\" class='link_2'>$username</td>"; 
    echo "</tr>"; 
    echo "<tr>"; 
    echo "<td></td>"; 
    echo "</tr>"; 
    $i++; 
    &#125; 
    ?> 
    
    </table> 
    
    <? &#125; else echo "Nessun topic presente"; ?>
    

  • User Attivo

    appena torno a casa lo provo subito spero tanto funzioni,
    grazie mille per la tua gentilezza !


  • User Attivo

    GRANDE funziona benissimo !


  • User

    @vision82 said:

    Ciao, piccola domanda da profano....ho provato lo script funziona perfettamente ma il problema che mi visualizza anche i post che vengono scritti nell'area dei moderatori, come faccio ad escludere quei post?

    SPero non sia troppo banale 😄

    Mi auto quoto, qualcuno sa rispondere?


  • Super User

    Ciao vision82.
    Cerca nel tuo script questo pezzo di codice```
    user_id WHERE forum_id!=0

    
    e prova ad aggiungere```
    AND forum_id!=x
    

    dove x sarà il numero ID della sezione moderatori sul tuo forum.

    Il codice finale sarà qualcosa del tipo:```
    user_id WHERE forum_id!=0 AND forum_id!=x

    
     :ciauz:

  • User

    Ottimo...anche se il mio codice era un pò diverso ora è tutto risolto...grazie ancora :ciauz:


  • User Attivo

    Sull mia home faccio visualizzare gli ultimi 10 topic

    Se volessi fare un altra pagina dove far visualizzare i topic da 11 a 100

    cosa devo cambiare nello script?


  • User Attivo

    giorgio tu ce l'hai sul tuo sito, ci metti due sec a rispondermi
    per favore !


  • Community Manager

    @alive said:

    giorgio tu ce l'hai sul tuo sito, ci metti due sec a rispondermi
    per favore !

    Si ovvio 😄

    Solamente che mi è sfuggito questo topic, ogni tanto salto qualche forum da leggere.

    Metti al posto del LIMIT 10

    LIMIT 11, 100

    Prova


  • User Attivo

    Thank you so much !

    Provo e poi ti faccio sapere !


  • User Attivo

    funziona 😄


  • User

    qualcuno per favore può ricapitolare.... :sbav: :sbav: :sbav:
    il codice completo da inserire nella home qual è?
    e poi cos'altro devo fare....???
    grazie mille


  • User Newbie

    Scusate, è il mio primo post, e faccio una domanda sicuramente molto stupida in quanto non so nulla di php.

    Ma che vuol dire mettere quel codice in homepage? Se non dentro un html, dove non funziona, dove?


  • User Newbie

    Ok! Comincio a capire!
    Ho fatto un file .php con dentro questo codice:

    <?
    error_reporting(E_ALL);
    echo "WOW !!!";
    mysql_connect("localhost", "[Utente]", "[password]");
    mysql_select_db("phpbb");

    $sql="SELECT * FROM phpbb_posts_text WHERE post_subject!='' ORDER BY post_id DESC LIMIT 10";
    $risultati=mysql_query($sql);
    while($riga=mysql_fetch_array($risultati)) {
    $target=$riga["post_subject"];
    $target1=$riga["post_id"];
    echo"<a href="http://www.terminillo.org/viewtopic.php?p=$target1" title="">$target</a>
    ";
    }//Fine del while
    ?>

    ma mi mostra solo la scritta "WOW!!!"
    Please, HELP ME! Dove sbaglio ora?
    @Tarivor said:

    Scusate, è il mio primo post, e faccio una domanda sicuramente molto stupida in quanto non so nulla di php.

    Ma che vuol dire mettere quel codice in homepage? Se non dentro un html, dove non funziona, dove?


  • User Newbie

    Ho trovato questo errore nell'error.log

    [Fri Jun 23 10:48:49 2006] [error] [client xxx.xxx.xxx.xxx] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/terminillo.org/httpdocs/ForumIndex.php on line 9

    :mmm:


  • User Newbie

    @Tarivor said:

    Ho trovato questo errore nell'error.log

    [Fri Jun 23 10:48:49 2006] [error] [client xxx.xxx.xxx.xxx] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/terminillo.org/httpdocs/ForumIndex.php on line 9

    :mmm:
    Ok! Ho risolto da solo! Mi ero dimenticato di valorizzare il nome del Database e la tabella si chiamava diversamente. :vai: