Php 显示所有主题标题上的图像

Php 显示所有主题标题上的图像,php,image,Php,Image,我正在尝试更改此php代码,以便在每个标题旁边显示图像,而不是第一个标题 更新代码: global $cache; $count_limit = 5; $title_limit = 30; $title_limit2 = 48; $time_limit = 86400; $forum_ids_arr = array(4,5,7,19,10,11); // separate with commas e.g. 1,2,3 @ini_set('memory_limit', '256M'); if

我正在尝试更改此php代码,以便在每个标题旁边显示图像,而不是第一个标题

更新代码

global $cache;

$count_limit = 5;
$title_limit = 30;
$title_limit2 = 48;
$time_limit = 86400;
$forum_ids_arr = array(4,5,7,19,10,11); // separate with commas e.g. 1,2,3

@ini_set('memory_limit', '256M');

if ( !empty($forum_ids_arr) ) {
foreach($forum_ids_arr as $fid) {
    $topic_with_img = array();
    $i = 0;

    while ( empty($topic_with_img) && $i < 20 ) {
        $sql = 'SELECT t.topic_id, t.topic_title, t.topic_poster,    t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_replies, p.post_text, p.bbcode_uid, p.poster_id
                        FROM ' . TOPICS_TABLE . ' t
                  LEFT JOIN ' . POSTS_TABLE . ' p
                              ON t.topic_first_post_id = p.post_id
                    WHERE t.forum_id = ' . $fid . '
                                AND p.bbcode_uid <> ""
                    ORDER BY t.topic_time DESC';

        $result = $db->sql_query_limit($sql, $count_limit, $count_limit*$i, $time_limit);

        while ($row = $db->sql_fetchrow($result)) {
            decode_message($row['post_text'], $row['bbcode_uid']);

            if ( strpos($row['post_text'], '[img]') === FALSE || strpos($row['post_text'], '[/img]') === FALSE ) {
                continue;
            } else {
                $row['post_text'] = " " . $row['post_text'];
              $ini = strpos($row['post_text'], "[img]");
              if ($ini == 0) {
                    $img_url = "";
                }
              $ini += strlen("[img]");
              $len = strpos($row['post_text'], "[/img]", $ini) - $ini;
              $img_url = substr($row['post_text'], $ini, $len);

                $topic_with_img['topic_id'] = $row['topic_id'];
                $topic_with_img['topic_title'] = $row['topic_title'];
                $topic_with_img['img_url'] = $img_url;


                $sql3 = 'SELECT forum_name
                                FROM ' . FORUMS_TABLE . '
                                WHERE forum_id = ' . $fid;
                $db->sql_query($sql3);
                $forum_name = $db->sql_fetchfield('forum_name');

                $topic_author_img       = get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']);
                $topic_replies_img = ($auth->acl_get('is_registered', $topic_forum_id)) ? strval($row['topic_replies_real']) : strval($row['topic_replies']);
                $comment = (intval($topic_replies) == 1) ? $user->lang['TT_COMMENT'] : $user->lang['TT_COMMENTS'];
                $topic_replies_img .= $comment;

                $template->assign_block_vars('img_top_topic', array(
                    'TITLE'        => (strlen($row['topic_title']) > $title_limit) ? substr($row['topic_title'], 0, $title_limit).'…' : $row['topic_title'],
                    'U_LINK'  => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't='.$row['topic_id']),
                    'IMG'     => $img_url,
                    'FORUM_NAME'  => $forum_name,
                    'FORUM_LINK'  => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f='.$fid),
                    'TOPIC_AUTHOR_IMG'       => $topic_author_img,
                    'TOPIC_REPLIES_IMG'         => $topic_replies_img,
                ));

                $sql5 = 'SELECT t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_replies, p.post_text, p.bbcode_uid, p.poster_id
                        FROM ' . TOPICS_TABLE . ' t
                  LEFT JOIN ' . POSTS_TABLE . ' p
                              ON t.topic_first_post_id = p.post_id
                    WHERE t.forum_id = ' . $fid . '
                                AND p.bbcode_uid <> ""
                    ORDER BY t.topic_time DESC';
                    $result2 = $db->sql_query_limit($sql5, $count_limit - 1, 1, $time_limit);


                while ($row2 = $db->sql_fetchrow($result2)) {
                    decode_message($row2['post_text'], $row2['bbcode_uid']);

                if ( strpos($row2['post_text'], '[img]') === FALSE || strpos($row2['post_text'], '[/img]') === FALSE ) {
                continue;
                } else {

                    $row2['post_text'] = " " . $row2['post_text'];
              $ini1 = strpos($row2['post_text'], "[img]");
              if ($ini1 == 0) {
                    $img_url1 = "";
                }
              $ini1 += strlen("[img]");
              $len1 = strpos($row2['post_text'], "[/img]", $ini1) - $ini1;
              $img_url1 = substr($row2['post_text'], $ini1, $len1);

                $topic_with_img1['topic_id'] = $row2['topic_id'];
                $topic_with_img1['topic_title'] = $row2['topic_title'];
                $topic_with_img1['img_url'] = $img_url1;


                $sql4 = 'SELECT forum_name
                                FROM ' . FORUMS_TABLE . '
                                WHERE forum_id = ' . $fid;
                $db->sql_query($sql4);
                $forum_name1 = $db->sql_fetchfield('forum_name');

                    $topic_author       = get_username_string('full', $row2['topic_poster'], $row2['topic_first_poster_name'], $row2['topic_first_poster_colour']);
                    $topic_replies = ($auth->acl_get('is_registered', $topic_forum_id)) ? strval($row2['topic_replies_real']) : strval($row2['topic_replies']);
                    $comment = (intval($topic_replies) == 1) ? $user->lang['TT_COMMENT'] : $user->lang['TT_COMMENTS'];
                    $topic_replies .= $comment;

                  $template->assign_block_vars('img_top_topic.last_top_topics', array(
                        'TITLE'        => (strlen($row2['topic_title']) > $title_limit2) ? substr($row2['topic_title'], 0, $title_limit2).'…' : $row2['topic_title'],
                        'TOPIC_AUTHOR'       => $topic_author,
                        'TOPIC_REPLIES'         => $topic_replies,  
                        'U_LINK'  => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't='.$row2['topic_id']),
                        'LAST_IMG'     => $img_url1,
                    ));
                    }
                }
                $db->sql_freeresult($result2);

                break;

            }
        }
        $db->sql_freeresult($result);

        if (empty($topic_with_img)) {
            $cache->destroy('sql');
        }

        $i++;
    }
}
}
global$cache;
$count_limit=5;
$title_limit=30;
$title_limit2=48;
$time_limit=86400;
$forum_ids_arr=数组(4,5,7,19,10,11);//用逗号分隔,例如1,2,3
@ini设置(“内存限制”、“256M”);
如果(!空($forum\u ids\u arr)){
foreach($forum\u id\u arr as$fid){
$topic_,带_img=array();
$i=0;
while(空($topic_with_img)和&$i<20){
$sql='选择t.topic\u id、t.topic\u title、t.topic\u poster、t.topic\u first\u poster\u name、t.topic\u first\u poster\u color、t.topic\u responses、p.post\u text、p.bbcode\u uid、p.poster\u id
来自“.TOPICS\u TABLE.”t
左连接“.POSTS_TABLE.”p
关于t.topic\u first\u post\u id=p.post\u id
其中t.forum_id='.$fid'
和p.bbcode\u uid“”
按t.topic_time DESC'排序;
$result=$db->sql\u query\u limit($sql,$count\u limit,$count\u limit*$i,$time\u limit);
while($row=$db->sql\u fetchrow($result)){
解码消息($row['post\u text'],$row['bbcode\u uid']);
if(strpos($row['post_-text'],'[img]')==FALSE | | strpos($row['post_-text'],'[/img]')==FALSE){
继续;
}否则{
$row['post_text']=''.$row['post_text'];
$ini=strpos($row['post_text'],“[img]”);
如果($ini==0){
$img_url=“”;
}
$ini+=strlen(“[img]”);
$len=strpos($row['post_text'],“[/img]”,$ini)-$ini;
$img_url=substr($row['post_text'],$ini,$len);
$topic_with_img['topic_id']=$row['topic_id'];
$topic_with_img['topic_title']=$row['topic_title'];
$topic_with_img['img_url']=$img_url;
$sql3='选择论坛名称
从“.FORUMS\u表”
其中forum_id='。$fid;
$db->sql\u查询($sql3);
$forum\u name=$db->sql\u fetchfield('forum\u name');
$topic_author_img=get_username_string('full',$row['topic_poster'],$row['topic_first_poster_name'],$row['topic_first_poster_color']);
$topic\u repress\u img=($auth->acl\u get('is\u registed',$topic\u forum\u id))?strval($row['topic\u repress\u real']):strval($row['topic\u repress']);
$comment=(intval($topic_represents)==1)?$user->lang['TT_comment']:$user->lang['TT_COMMENTS'];
$topic\u repress\u img.=$comment;
$template->assign_block_vars('img_top_topic',数组(
“TITLE”=>(strlen($row['topic\u TITLE'])>$TITLE\u limit)?substr($row['topic\u TITLE'],0,$TITLE\u limit)。“…”:$row['topic\u TITLE'],
'U_LINK'=>append_sid({$phpbb_root_path}viewtopic.$phpEx','t='.$row['topic_id']),
“IMG”=>$IMG\u url,
“论坛名称”=>$FORUM\u NAME,
“论坛链接”=>append_sid({$phpbb_root_path}viewforum.$phpEx“,'f='.$fid),
'TOPIC\u AUTHOR\u IMG'=>$TOPIC\u AUTHOR\u IMG,
“TOPIC\u REPLIES\u IMG”=>$TOPIC\u REPLIES\u IMG,
));
$sql5='选择t.topic\u id、t.topic\u title、t.topic\u poster、t.topic\u first\u poster\u name、t.topic\u first\u poster\u color、t.topic\u responses、p.post\u text、p.bbcode\u uid、p.poster\u id
来自“.TOPICS\u TABLE.”t
左连接“.POSTS_TABLE.”p
关于t.topic\u first\u post\u id=p.post\u id
其中t.forum_id='.$fid'
和p.bbcode\u uid“”
按t.topic_time DESC'排序;
$result2=$db->sql\u query\u limit($sql5,$count\u limit-1,1,$time\u limit);
而($row2=$db->sql\u fetchrow($result2)){
解码消息($row2['post\u text'],$row2['bbcode\u uid']);
if(strpos($row2['post_-text'],'[img]')==FALSE | | strpos($row2['post_-text'],'[/img]')==FALSE){
继续;
}否则{
$row2['post_text']=''.$row2['post_text'];
$ini1=strpos($row2['post_text'],“[img]”);
如果($ini1==0){
$img_url1=“”;
}
$ini1+=strlen(“[img]”);
$len1=strpos($row2['post_text'],“[/img]”,$ini1)-$ini1;
$img_url1=substr($row2['post_text'],$ini1,$len1);
$topic_with_img1['topic_id']=$row2['topic_id'];
$topic_with_img1['topic_title']=$row2['topic_title'];
$topic_with_img1['img_url']=$img_url1;
$sql4='选择论坛名称
从“.FORUMS\u表”
其中forum_id='。$fid;
$db->sql\u查询($sql4);
$forum\u name1=$db->sql\u fetchfield('forum\u name');
$topic_author=get_username_string('full',$row2['topic_poster'],$row2['topic_first_poster_name'],$row2['topic_first_poster_color']);
$topic\u repress=($auth->acl\u get($is\u registed',$topic\u forum\u id))?strval($row2['topic\u repress\u real']):strval($row2['topic\u repress']);
$comment=(intval($topic_represents)==1)?$user->lang['TT_comment']:$user->lang['TT_COMMENTS'];
$topic_responses.=$comment;
$template->assign_block_vars('img_top_topic.last_top_topics',数组(
“TITLE”=>(strlen($row2['topic\u TITLE'])>$TITLE\u limit2)?substr($row2['topic\u TITLE'],0,$TITLE\u limit2)。“…”:$row2['topic\u TITLE'],
“主题作者”=>$TOPIC作者,
<div class="tt">
<!-- BEGIN img_top_topic -->
<div class="tt_column<!-- IF img_top_topic.S_ROW_COUNT == 0 or     img_top_topic.S_ROW_COUNT == 3 --> one<!-- ELSEIF img_top_topic.S_ROW_COUNT == 1 or img_top_topic.S_ROW_COUNT == 4 --> two<!-- ELSEIF img_top_topic.S_ROW_COUNT == 2 or img_top_topic.S_ROW_COUNT == 5 --> three<!-- ENDIF -->">
    <h3 <!-- IF img_top_topic.S_ROW_COUNT > 2 -->style="margin-top: 20px;"<!-- ENDIF -->><a href="{img_top_topic.FORUM_LINK}">{img_top_topic.FORUM_NAME}</a></h3>


        <ul>
        <div class="imgresize"><a href="{img_top_topic.U_LINK}"><img src="{img_top_topic.IMG}" alt="{img_top_topic.TITLE}" /></a></div>
        <li class="one"><a class="img_title" href="{img_top_topic.U_LINK}">{img_top_topic.TITLE}</a></li>
        <li class="topic_title_span"><span>by {img_top_topic.TOPIC_AUTHOR_IMG} |{img_top_topic.TOPIC_REPLIES_IMG}</span></li>
        </ul>


    <!-- BEGIN last_top_topics -->
        <ul>
        <div class="imgresize"><a href="{last_top_topics.U_LINK}"><img src="{last_top_topics.LAST_IMG}" alt="{last_top_topics.TITLE}" /></a></div>
        <li class="one"><a class="img_title" href="{last_top_topics.U_LINK}">{last_top_topics.TITLE}</a></li>
        <li class="topic_title_span"><span>by {last_top_topics.TOPIC_AUTHOR} |{last_top_topics.TOPIC_REPLIES}</span></li>
        </ul>

    <!-- END last_top_topics -->        

</div>