vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Pulling thread title from query (https://vborg.vbsupport.ru/showthread.php?t=49743)

Boofo 03-07-2003 03:05 AM

Pulling thread title from query
 
What I'm trying to do with the code below is pull both the post title (if there is one) and the thread title from the getlastposts query. What I want it to do is is show "Re: threadtitle" is there is no post title. Can someone please tell me what I am doing wrong?

PHP Code:

$totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,post.title,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$threadtitle=$getlastpost[title];
        
$threadtitle=censortext($threadtitle);
        
$threadtitle=htmlspecialchars($threadtitle);
        
$threadtitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $threadtitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";
        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate("getinfo_latestposts")."\";"); 


mr e 03-07-2003 04:17 AM

then you'd do something like this

PHP Code:

$totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,post.title,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$threadtitle=$getlastpost[title];
        
$threadtitle=censortext($threadtitle);
        
$threadtitle=htmlspecialchars($threadtitle);
        
$threadtitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $threadtitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";

if (
$posttitle == "") { //only part i changed
$posttitle "Re: $threadtitle";//
}//

        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate
("getinfo_latestposts")."\";"); 


Boofo 03-07-2003 04:22 AM

Here's what i want to do. I want it to loist like this:

posttitle (Thread: threadtitle)

Will this do this? And how can I get the actual number of posts if a user has less than 10 posts?

mr e 03-07-2003 04:25 AM

loist?

anyways, so if there is no post title you want the post title to be "Re: $threadtitle" where $threadtitle is the title of the thread?

Boofo 03-07-2003 04:25 AM

Here's the code I am working with now. I took out all the other stuff because it wasn't working.

PHP Code:

  $totalposts=$userinfo[posts];
  if (
$totalposts!=or $userinfo[lastpost]!=0) {
    
$getlastposts=$DB_site->query("SELECT thread.title,thread.threadid,thread.forumid,postid,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND post.userid=$userinfo[userid] AND post.visible=1 ORDER BY post.dateline DESC");
    
$postctr=0;
    
$latestposts="";
    while (
$getlastpost=$DB_site->fetch_array($getlastposts)) {
      
$getperms=getpermissions($getlastpost[forumid],$bbuserinfo[userid],$bbuserinfo[usergroupid]);
      if (
$getperms[canview]==1) {
        
$postdate=vbdate($dateformat,$getlastpost[dateline]);
        
$posttime=vbdate($timeformat,$getlastpost[dateline]);
        
$posttitle=$getlastpost[title];
        
$posttitle=censortext($posttitle);
        
$posttitle=htmlspecialchars($posttitle);
        
$posttitle=preg_replace("/(\[)(you)(])/siU"$bbuserinfo[username], $posttitle);
        
$posturl="showthread.php?postid=$getlastpost[postid]#post$getlastpost[postid]";

if (
$posttitle == "") { //only part i changed
$posttitle "Re: $threadtitle";//
}//

        
$postctr++;
        if (
$postctr==1){
          
$lastpostdate=$postdate;
          
$lastposttime=$posttime;
          
$lastposttitle=$posttitle;
          
$lastposturl=$posturl;
        }
        eval(
"\$latestposts .= \"".gettemplate("getinfo_latestposts")."\";");
        if (
$postctr==$showposts) {
         break;
        }
      }
    }
  } else {
  eval(
"\$latestposts .= \"".gettemplate("getinfo_latestpostsnone")."\";"); 


Boofo 03-07-2003 04:27 AM

Quote:

Originally posted by mr e
loist?

anyways, so if there is no post title you want the post title to be "Re: $threadtitle" where $threadtitle is the title of the thread?

Yes, sir. I want to have the thtreadtitle after it on all of them, too. I thought I had it once but I got messed up somewhere. ;)

mr e 03-07-2003 04:29 AM

well i look at the query and you aren't getting the post title, you have thread.title so your $posttitle=$getlastpost[title] is really your thread title

is this out of a php file or did you modify it?

Boofo 03-07-2003 04:30 AM

Quote:

Originally posted by mr e
loist?


loist=look

LOL My damned keyboard can't spell.

mr e 03-07-2003 04:30 AM

so you want the post's title AND the thread's title?

Boofo 03-07-2003 04:31 AM

Quote:

Originally posted by mr e
well i look at the query and you aren't getting the post title, you have thread.title so your $posttitle=$getlastpost[title] is really your thread title

is this out of a php file or did you modify it?

It's from an older hack I am updating for my site. How do we get the post title out of that query?


All times are GMT. The time now is 01:42 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01137 seconds
  • Memory Usage 1,797KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete