แสดงกระทู้ล่าสุด ในหน้าแรก phpbb3
  • <?
    include("/config.php");

    $db=mysql_connect ($dbhost,$dbuser,$dbpasswd) or die ("Error!");
    mysql_select_db("$dbname");
    mysql_db_query($dbname,"SET NAMES utf8");

    $qboard='select T.topic_id, T.topic_title, U.username, T.topic_time, T.topic_replies, T.topic_poster, P.post_username, T.topic_views, T.topic_replies
    from '.$table_prefix.'topics as T
    left join '.$table_prefix.'posts as P on T.topic_first_post_id=P.post_id
    left join '.$table_prefix.'users as U on U.user_id=T.topic_poster
    order by T.topic_last_post_id desc limit 10';
    $rboard=mysql_query($qboard, $db) or die("Error".mysql_error());

    ?>
    <div align="left"></div>
    <table width="470" align="center">
    <tr>
    <td align="center">Topic</td>
    <td align="center">Post</td>
    <td align="center">Rd/Rply</td>
    <td align="center">Reply</td>
    <td align="center">Date</td>
    </tr>
    <?
    while ($rowb=mysql_fetch_array($rboard)) {
    echo '<tr>';
    //echo '<td>'.$rowb[0].'</td>';
    echo '<td><a href="board/viewtopic.php?t='.$rowb[0].'" target="_blank">'.substr($rowb[1], 0, 100).'</a></td>';

    if($rowb[5]==-1) echo '<td><strong>'.$rowb[6].'</strong></td>';
    else echo '<td><strong>'.$rowb[2].'</strong></td>';

    echo '<td>'.$rowb[7].'/'.$rowb[8].'</td>';

    if ($rowb[4]!=0) {
    $qboard2='select U.username, P.post_time, P.poster_id, P.post_username
    from '.$table_prefix.'posts as P
    left join '.$table_prefix.'users as U on U.user_id=P.poster_id
    where P.topic_id='.$rowb[0].' order by P.post_time desc limit 1';
    $rboard2=mysql_query($qboard2, $db);
    $rowb2=mysql_fetch_array($rboard2);

    if($rowb2[2]==-1) echo '<td><strong>'.$rowb2[3].'</strong></td>';
    else echo '<td><strong>'.$rowb2[0].'</strong></td>';

    echo '<td>'.date("d.m.y", $rowb2[1]).'&nbsp;</td>';
    }
    else {
    echo '<td>N/A</td>';
    echo '<td>'.date("d.m.y", $rowb[3]).'</td>';
    }
    echo '</tr>';
    }
    ?>
  • 2 Comments sorted by
  • mysql_db_query($dbname,"SET NAMES utf8");

    ในกรณี การแสดงผลเป็น ???????? ให้แก้ตรง SET NAMES utf8 ไปเป็นระบบเดียวกะเว็บบอร์ด

    Cr: DevilDogTG
  • ฮอ... ขอบคุงฮับ :idea: