1

Topic: How to display with extern.php

hi all.

First great script!

My question is this. I can dispaly the latest topic with extern.php, yet it only shows the topic. How can i show who posted the topic, as well as the date and time posted with the topic?

im using this now:

http://www.theharvestnetwork.net/punbb/ … ion=active

after looking in the extern.php, I see some code that has this info under the stats section?

Im new to php, i can read most codes, but cant write it to well yet :-)

Thanks in Advance
Daryl

Re: How to display with extern.php

There is currently no way of doing that without hacking extern.php a bit. I'm terribly busy at the moment, but perhaps someone else can put a little something together for you?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: How to display with extern.php

Ok Thanks Rickard,

I was looking at the code, If im not mistaken i would have to work on this in  this area?

// Fetch $show topics
        $result = $db->query('SELECT t.id, t.subject,  FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

        while ($cur_topic = $db->fetch_assoc($result))
        {
            if ($pun_config['o_censoring'] == '1')
                $cur_topic['subject'] = censor_words($cur_topic['subject']);

            if (pun_strlen($cur_topic['subject']) > $max_subject_length)
                $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
            else
                $subject_truncated = $cur_topic['subject'];

            echo '<b>·</b> <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a><br>'."\n";
        }
    }

    exit;
}


If one of you experts out there could point me in the right direction that would be awsome.

Thanks So much
Daryl

Re: How to display with extern.php

Yes, that's right. What you want to do is to fetch more fields from the database (e.g. t.poster and t.lastpost or something) and then echo them out as you see fit.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: How to display with extern.php

ok, :-)

After studying this section of code for awhile i have figured out how you made them link to the form topic. :-)

I understand to add the fields in the string:

$result = $db->query('SELECT t.id, t.subject,  FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show)


I would add this as such:

$result = $db->query('SELECT t.id, t.subject, <b>((Somthing)))</b> FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show)

From the looks of this, it looks like that there had been a joining of tables.

ok the only real problem I have is the echo thing.

In the script I do not see any echo for the ' t.id, t.subject ' ?

Im very sorry for all the questions guys, I am tring to learn PHP so i want have to ask so many :-)


Could someone please use this script and put an example in it how to add a different field? Then i can build on that information .

// Fetch $show topics
        $result = $db->query('SELECT t.id, t.subject,  FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON t.forum_id=f.id WHERE t.moved_to IS NULL AND '.$forum_sql.'f.admmod_only=0 ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

        while ($cur_topic = $db->fetch_assoc($result))
        {
            if ($pun_config['o_censoring'] == '1')
                $cur_topic['subject'] = censor_words($cur_topic['subject']);

            if (pun_strlen($cur_topic['subject']) > $max_subject_length)
                $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
            else
                $subject_truncated = $cur_topic['subject'];

            echo '<b>·</b> <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a><br>'."\n";
        }
    }

    exit;




Thanks so much
Daryl

6

Re: How to display with extern.php

Hey Guys,

I know someone out there can help me on this. :-)

Just need to find out how to put the echo on this mainly.

thanks
Daryl