Topic: COde

Why isn't this working?

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != ''){        
        $tmp = $db->query('SELECT subject FROM '.$db->prefix.'topics WHERE last_post_id="'.$cur_forum['last_post_id'].'"');
         $topic_subject = $db->fetch_assoc($tmp);
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.$topic_subject['subject'].'</a><br />'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']); 
        } 
    else
        $last_post = ' ';

That's from index.php. I'm trying to make it so it shows the topic subject instead of the date.

Re: COde

Well, for one thing, I don't think by is in lang_common tongue

Re: COde

Smartys wrote:

Well, for one thing, I don't think by is in lang_common tongue

I don't care about that... It's an all English fourm.

4 (edited by Smartys 2005-02-03 23:37)

Re: COde

No, the point is the word by won't appear if it's not there tongue

Oww, my mistake it is tongue
*smacks himself, thinking of 1.1.5*

Missing <span class="byuser> as well

Re: COde

Smartys wrote:

No, the point is the word by won't appear if it's not there tongue

Oww, my mistake it is tongue
*smacks himself, thinking of 1.1.5*

Missing <span class="byuser> as well

Yeah w/e can you help me with the original code?

Re: COde

Well, I believe it will look oddly without the span (I'm guessing here tongue) but OK
As for the code, I would assume the while loop is the problem: see if you can integrate the query before or during the really long one?

7

Re: COde

It would help if you said what your code actually outputs i.e. in exactly what way is it not working.

8 (edited by Smartys 2005-02-04 00:53)

Re: COde

I tried it on my local forum: only the first topic loads wink

Re: COde

Smartys wrote:

I tried it on my local forum: only the first topic loads wink

So it is the while loop? I don't understand richard didn't put the post subject in with the post itself in the database.

10

Re: COde

I would really appreciate it if someone can help me get this working.

11

Re: COde

I had an idea. Instead of changing much in index.php why not change post.php. I added this

$db->query("UPDATE ".$db->prefix."forums SET last_post_subject='".$subject."' WHERE last_post_id='$now'") or error('Unable to update topic', __FILE__, __LINE__, $db->error());

on line 286 and my select statement on my index php file looks like thos

$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post_subject, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

Now everything works well but this. When I make a post it redirects me all the time to http://url.com/viewtopic.php?pid=0#p0

Re: COde

John08 wrote:
Smartys wrote:

I tried it on my local forum: only the first topic loads wink

So it is the while loop? I don't understand richard didn't put the post subject in with the post itself in the database.

You can do that: I believe the way PunBB keeps the data current is in functions.php: add a column in the database and change it in the right function and it will be kept for you wink