View Full Version : Latest post id and thread id on index page
freakyshiat
07-05-2002, 03:18 PM
how can I do that?
thanks...
g-force2k2
07-05-2002, 03:50 PM
there's a hack for something similar... try searching the hacks database or just the hacks list themselves :D
g-force2k2
freakyshiat
07-05-2002, 05:25 PM
theres a hack that counts the posts in a thread, like what is installed at this site ; I guess I need a simple database query that will grab the latest post and thread id and output that on the index page
g-force2k2
07-05-2002, 05:49 PM
open index.php
find:
// get total posts
under it add:
// +++++++ Last Post Thread ID [ Start ] +++++++
$getid=$DB_site->query('SELECT threadid FROM thread ORDER BY lastpost DESC LIMIT 1');
$id=$getid[threadid];
$lastthread="<a href=\"showthread.php?s=$session[sessionhas]&threadid=$id">$id</a>";
// +++++++ Last Post Thread ID [ End ] +++++++
then in the forumhome template place [php]$lastthread[/php where you want it to appear... it'll display the number like you were looking for...
i think this'll work but not positive and not sure if this is what you were looking for?
g-force2k2
freakyshiat
07-05-2002, 06:22 PM
yeah u have the right idea but its generating a blank index page when I add your code :)
g-force2k2
07-05-2002, 06:43 PM
well i'll take a look and repost it in a few... you want the id number though yes? not the name? i'll test it... didn't try i yet...
g-force2k2
Edit: just saw i forgot to block out coding ;\ and you didn't get a parse error?
replace the coding i gave you with this instead:
// +++++++ Last Post Thread ID [ Start ] +++++++
$getid=$DB_site->query('SELECT threadid FROM thread ORDER BY lastpost DESC LIMIT 1');
$id=$getid[threadid];
$lastthread="<a href=\"showthread.php?s=$session[sessionhas]&threadid=$id\">$id</a>";
// +++++++ Last Post Thread ID [ End ] +++++++
Try this:
$threadinfo=$DB_site->query_first("select thread.threadid, thread.title, lastpost, lastposter, post.postid from thread left join post on (post.\
threadid = thread.threadid) where forumid = $forumid order by postid desc limit 1;");
echo "<a href=\"showthread.php?s=$session[sessionhash]&postid=$threadinfo[postdid]#post$threadinfo[postid]\">$threadinfo[title]</a>";
g-force2k2
07-05-2002, 07:02 PM
Zzed you forgot to block the quote at the end ;) and i believe that Fazle wants the number not the name ;)
g-force2k2
LOL @ g-kforce2k2 :D:D:D
And you spelled sessionhash as sessionhas. ;)
freakyshiat
07-05-2002, 08:16 PM
Zzed thanks for the help, but yeah I just want the number ; the latest threadid and postid.
g-force2k2, I added the new code but when I add the $lastthread in forumhome, no number comes up ; index page doesnt show up as blank anymore, but the threadid doesnt show up either :)
freakyshiat
07-05-2002, 08:19 PM
Originally posted by Zzed
LOL @ g-kforce2k2 :D:D:D
And you spelled sessionhash as sessionhas. ;)
:p
I fixed the error but no go :p
g-force2k2
07-05-2002, 08:23 PM
lol thanks Zzed :)
btw Fazle just makre sure you fixed the sessionhash in mine and also i'll test in a few for you ;)
g-force2k2
freakyshiat
07-05-2002, 08:28 PM
Originally posted by g-force2k2
lol thanks Zzed :)
btw Fazle just makre sure you fixed the sessionhash in mine and also i'll test in a few for you ;)
g-force2k2
yeah i fixed the sessionhash but no go :p
thanks for helping me...and if you do get it working, tell me how to do the postid also if u have time :)
thanks again
g-force2k2
07-05-2002, 09:59 PM
Here's a screenshot of what i believe that you wanted as well as the coding :) Enjoy...
---------------------
open index.php
---------------------
find:
// get total posts
above it add:
// +++++++ Last Post Thread ID [ Start ] +++++++
$getid=$DB_site->query("SELECT threadid FROM thread ORDER BY lastpost DESC LIMIT 1");
while ($threads = mysql_fetch_array($getid)) {
$lastthread="<a href=\"showthread.php?s=$session[sessionhash]&threadid=$threads[threadid]\">$threads[threadid]</a>";
}
$getpid=$DB_site->query("SELECT postid FROM post ORDER BY postid DESC LIMIT 1");
while ($postings = mysql_fetch_array($getpid)) {
$lastpost="<a href=\"showthread.php?s=$session[sessionhash]&postid=$postings[postid]\">$postings[postid]</a>";
}
// +++++++ Last Post Thread ID [ End ] +++++++
Then open up the forumhome template and place
$lastpost $lastthread
where ever you want you can customize from there im sure you can :)
g-force2k2
Chris M
07-05-2002, 10:03 PM
Scrap that...Dont work:)
Satan
Chris M
07-05-2002, 10:14 PM
There is an update, should you prefer to use templates...
Input this code instead of g-force's :
// +++++++ Last Post Thread ID [ Start ] +++++++
$getid=$DB_site->query("SELECT threadid FROM thread ORDER BY lastpost DESC LIMIT 1");
while ($threads = mysql_fetch_array($getid)) {
eval("\$lastthread = \"".gettemplate("lastthread_id")."\";");
}
$getpid=$DB_site->query("SELECT postid FROM post ORDER BY postid DESC LIMIT 1");
while ($postings = mysql_fetch_array($getpid)) {
eval("\$lastpost = \"".gettemplate("lastpost_id")."\";");
}
// +++++++ Last Post Thread ID [ End ] +++++++
Now make 2 templates, :
lastthread_id
<a href="showthread.php?s=$session[sessionhash]&threadid=$threads[threadid]">$threads[threadid]</a>
lastpost_id
<a href="showthread.php?s=$session[sessionhash]&postid=$postings[postid]">$postings[postid]</a>
Now just put $lastthread and $lastpost in the forumhome template...
Satan
g-force2k2
07-05-2002, 10:16 PM
lol thanks hellsatan :) i like using both but i think that eval() uses queries so i thought i'd just give it to himi in that form... but one thing yours is definately easier to customize ;)
g-force2k2
Chris M
07-05-2002, 10:19 PM
Yeh...
I changed it anyway, to give the last post...
Satan
g-force2k2
07-05-2002, 10:24 PM
yeah but he doesn't want the name he just said he wanted the id number :P at least thats what he said... just the last threadid and postid ;\ dunno :p
g-force2k2
Chris M
07-05-2002, 10:29 PM
I just added Most viewed thread too:D
I like those kinda thingys:)
I wonder if you can put variables in your Signature?:confused:
Satan
g-force2k2
07-05-2002, 10:37 PM
i doubt it because it won't run php :p so you'll just end up with variables :)
g-force2k2
freakyshiat
07-06-2002, 07:08 PM
wow, great work guys ; just what i wanted.
Now one last thing.....for example my last postid is 4758632 ; how is it possible to make it appear like 4,758,632? :)
thanks again, great work :)
g-force2k2
07-06-2002, 07:42 PM
sorry Fazle i have an idea but i can't really say ;\ i just learning so you'll probably get another person to help you with what you wanted ;)
g-force2k2
freakyshiat
07-06-2002, 07:52 PM
Originally posted by g-force2k2
sorry Fazle i have an idea but i can't really say ;\ i just learning so you'll probably get another person to help you with what you wanted ;)
g-force2k2
thats ok, thanks for your help... I think 'number_format' needs to be in there somewhere....I dunno :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.