Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di cnc
    Registrato dal
    Dec 1999
    Messaggi
    158

    determinati topic dal forum

    Dunque, ho già visto nel forum qualche cosa di marginale alla mia richiesta ma nulla che si avvicini di +, quindi apro un topic nuovo.

    Ho un forum e un home page, entrambi in php.

    In HP ho una tabella con tre celle in orizzontale. Vorrei che in ognuna di essa apparisser rispettivamente il titolo, tot caratteri del testo, e il link (eventualmente, in altre due celle, data e autore)

    Il testo deve però riferirsi a quello di apertura e non a quello dell'ultima risposta (ho trovato infatti uno script che mi carica l'ultimo topic e l'ultimo post... io invece vorrei, in generale, l'ultimo topic e il primo post, nello specifico un determinato topic e il suo primo post).

    potete postarmi un codice utile? thx

  2. #2
    Quale forum stai usando?
    Come sono strutturate le tabelle?

  3. #3
    Utente di HTML.it L'avatar di cnc
    Registrato dal
    Dec 1999
    Messaggi
    158
    IPB forum...

    quoto lo script che avevo trovato così riesco a spiegare meglio come sono strutturate le tabelle (non sono capace in altro modo )


    codice:
    <?php
    	
    ////////////////////////////////////////
    // Shorten Function - No Need to edit //
    ////////////////////////////////////////
    
    function shorten($text, $length)
    {
        if(strlen($text) > $length)
        {
            $text = substr(trim($text), 0, $length - 3);
            $shorten_by = strlen(strrchr($text, " "));
            if($shorten_by > 0 && $shorten_by < $length / 2) $text = substr($text, 0, -$shorten_by);
            while(preg_match("/[-,.]$/i", $text)) $text = substr($text, 0, -1);
            $text .= "...";
        }
        return htmlentities($text);
    }
    
    //
    // Include most recent news from database
    //
    // Edit the database variables to match your invision database.
    // Edit the forum id to match that of the forum in which you wish to extract posts from.
    //
    
    $db = mysql_connect("localhost", "username", "password");
    mysql_select_db("database name", $db);
    
    $newsheadline = mysql_query("SELECT * FROM ibf_topics WHERE forum_id='1' ORDER BY 'tid' DESC LIMIT 1", $db);
    $news = mysql_query("SELECT * FROM ibf_posts WHERE forum_id='1' ORDER BY 'pid' DESC LIMIT 1", $db);
    $rows = mysql_num_rows($newsheadline);
    $rows--;
    $link = mysql_result($newsheadline, $rows, 'tid');
    $title = mysql_result($newsheadline, $rows, 'title')  or mysql_error($db);
    $rows = mysql_num_rows($news);
    $rows--;
    $bodyo  = mysql_result($news,$rows,'post');
    $bodyo = shorten($bodyo, "325");
    
    // Edit the paths to match your forum.
    // Note: The path must relevant to your web root ( If you place this file in www.yourdomain.com/football,
    // then the path would be ../yourforum/index.php?showtopic=$link\">Click Here to read the full story..</a>";
    $info ="<a href=\"./yourforum/index.php?showtopic=$link\">Click Here to read the full story..</a>";
    $body.="<a href=\"./yourforum/index.php?showtopic=$link\">$title</a>";
    
    // Display Title
    $body = html_entity_decode($body);
    print $body;
    
    //
    // End of Include             
    //
    ?>
    
    <div align="center"></div></td>
    </tr>
    <tr>
    <td height="63" bgcolor="#EEF1F8">
    <table width="90%"  border="0" align="center">
    <tr>
    <td>
    
    <?php // Display post 
    	$bodyo = html_entity_decode($bodyo);
    		print $bodyo;?>
    
    
    
    <?php // Display Link
    	$info = html_entity_decode($info);
    		print $info;?>
    </p>

  4. #4
    Utente di HTML.it L'avatar di cnc
    Registrato dal
    Dec 1999
    Messaggi
    158
    up

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.