Mindcontroll Forum Index Mindcontroll

 

Help Goto Last thread.
Click here to go to the original topic

 
       Mindcontroll Forum Index -> Programs/Programming Development
View previous topic :: View next topic  
Author Message
M0nKeY



Joined: 09 Feb 2002
Posts: 1235

Posted: 11-05-2002 11:55 PM    Post subject: Help Goto Last thread.  

Can somone turn this into "Goto Last THREAD"?
Code:
// goto last post
if ($goto=="lastpost") {
  if (isset($threadid) and $threadid!=0) {
    $threadid = verifyid("thread",$threadid);

    if ($getlastpost=$DB_site->query_first("SELECT postid,post.dateline FROM post,thread WHERE post.threadid=thread.threadid AND thread.threadid='$threadid' AND post.visible=1 AND thread.visible=1 ORDER BY post.dateline DESC LIMIT 1")) {
      header("Location: shownews.php?s=$session[sessionhash]&postid=$getlastpost[postid]");
      exit;
    }
  }
  if (isset($forumid) and $forumid!=0) {
    $foruminfo=verifyid("forum",$forumid,1,1);
    $forumid=$foruminfo['forumid'];

      $forumslist = "";
      $getchildforums=$DB_site->query("SELECT forumid,parentlist FROM forum WHERE INSTR(CONCAT(',',parentlist,','),',$forumid,')>0");
      while ($getchildforum=$DB_site->fetch_array($getchildforums)) {
         if ($getchildforum[forumid]==$forumid) {
            $parentlist=$getchildforum[parentlist];
         }
         $forumslist.=",$getchildforum[forumid]";
      }

    $thread=$DB_site->query_first("SELECT threadid FROM thread WHERE forumid IN (0$forumslist) AND visible=1 AND (sticky=1 OR sticky=0) AND lastpost>='".($foruminfo[lastpost]-30)."' AND open<>10 ORDER BY lastpost DESC LIMIT 1");

    if ($getlastpost=$DB_site->query_first("SELECT postid FROM post WHERE threadid='$thread[threadid]' AND visible=1 ORDER BY postid DESC LIMIT 1")) {
      header("Location: shownews.php?s=$session[sessionhash]&postid=$getlastpost[postid]");
      exit;
    }
  }
}
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-06-2002 01:32 AM    Post subject:  

Try changing:
Code:
header("Location: shownews.php?s=$session[sessionhash]&postid=$getlastpost[postid]");


to:

Code:
header("Location: shownews.php?s=$session[sessionhash]&postid=$getlastpost[postid]&#$getlastpost[postid]");


(Oh my god, is that vb code, cause they could have made it look so much better... tsk. tsk. )
Back to top  
M0nKeY



Joined: 09 Feb 2002
Posts: 1235

Posted: 11-06-2002 01:38 AM    Post subject:  

Um no... I want it to return the last THREAD number.. not goto a POSt. Dur.
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-06-2002 02:21 AM    Post subject:  

Well, the piece of code you pasted is for going to the last post, I dont think it has anything to do with the last thread on the board. But, threads and posts are seperated in the database, so all you have to do is query the database to give you the last (or 10) thread(s) where the forumid is the forumid of the news page. (I am right here, am I not?)

I cant really help tough, I have to work on some stuff first, after that comes some more stuff, and after that I am free to do whatever I want.

Code:
$query = "SELECT * FROM threads WHERE forumid = '".$forumid."' ORDER BY threadid LIMIT 0, 5";
Back to top  
Dawgy



Joined: 09 Feb 2002
Posts: 463

Posted: 11-06-2002 06:16 AM    Post subject:  

VB is satan (according to pezko)

Oh, and if you really want to see BAD BAD php, look at phpnuke
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-06-2002 08:14 AM    Post subject:  

Soon, very, very soon, ill start working on my own CMS, ala djammhaus and shn's system, only with a personal forum and and ratings! So basically im gonna try making what we discussed earlier, and im already writing classes for it, cause im using that code in my current project as well. (CMS for my dads company).
I dont want any help tough! Working alone is so much easier then working in a group. Dont count on seeing it before I finished it as well, wich will take quite some time.
Back to top  
Pezko



Joined: 09 Feb 2002
Posts: 186

Posted: 11-06-2002 10:09 AM    Post subject:  

*questions the relevance of TumTum's latest post in this thread*

*points out that working in group is much more efficient if properly managed*
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-06-2002 12:13 PM    Post subject:  

lol, pezko, you think you could handle a group with all the lunatics we have in the chan? Anyway, mine will just be something simple.
Back to top  
Shn



Joined: 10 Feb 2002
Posts: 738

Posted: 11-06-2002 02:26 PM    Post subject:  

TuMTuM wrote:
Code:
$query = "SELECT * FROM threads WHERE forumid = '".$forumid."' ORDER BY threadid LIMIT 0, 5";


taking tumtum's code as a base, here's the last thread:

Code:
$query = "SELECT * FROM threads WHERE forumid = '$forumid' ORDER BY threadid DESC LIMIT 1;";


what i changed: putting ".$forumid." is useless cause the query is between 2 "... at least i think it works like echo, print,...

i added 'DESC' so it'll be ordered in DESCending order...
and LIMIT 1 cause you just want one thread.
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-06-2002 02:30 PM    Post subject:  

Its called proper coding, I have all my strings outside of the "s or 's. And I tought stuff got sorted DESC automatically. anyway, i was at work when I posted that and didnt bother looking anything up.
Back to top  
Pezko



Joined: 09 Feb 2002
Posts: 186

Posted: 11-06-2002 02:59 PM    Post subject:  

Quote: Its called proper coding, I have all my strings outside of the "s or 's.
K. Proper coding... And why isn't it proper coding to do like Shn did?

Quote: lol, pezko, you think you could handle a group with all the lunatics we have in the chan?
Withdraws statement... :D
Back to top  
Shn



Joined: 10 Feb 2002
Posts: 738

Posted: 11-06-2002 05:26 PM    Post subject:  

i always use ' for queries and echos... except for a few very rare exceptions.

And, if it isn't proper coding to put echo "$boop";
then MANY php programmers don't code properly.

Oh, and proper coding requires to know what the stuff you code does, don't you think ?


Now, about the group work. There are indeed some people in the chan that couldn't work as a group (or at all). But some of us are able to share ideas and code and help each other in an intelligent way.
I'm sure a few of the people in the chan are able to communicate correctly their ideas.

k, bye.
Back to top  
Pezko



Joined: 09 Feb 2002
Posts: 186

Posted: 11-06-2002 05:50 PM    Post subject:  

Shn wrote:
Now, about the group work. There are indeed some people in the chan that couldn't work as a group (or at all). But some of us are able to share ideas and code and help each other in an intelligent way.
I'm sure a few of the people in the chan are able to communicate correctly their ideas.

k, bye.

Yes, few...
Back to top  
TuMTuM



Joined: 17 Feb 2002
Posts: 425

Posted: 11-07-2002 02:36 AM    Post subject:  

Can I close this thread? Its gone way off topic and is starting to become a flame war. Yeah, ill close it, if you want to reopen it, only do so because you want to get back ontopic.
Back to top  
 
       Mindcontroll Forum Index -> Programs/Programming Development
Page 1 of 1


Video Games Suck - XXXSwim