vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   help with vbulletin select statement from a forum (https://vborg.vbsupport.ru/showthread.php?t=174959)

DionDev 04-02-2008 10:08 PM

help with vbulletin select statement from a forum
 
i wrote this myseld and it doesn't seem to be working correctly. it only shows me 2 of the 3 threads in the specified forum (4)

PHP Code:

<?
$dbhost = 'localhost';
$dbname = '*****';
$dbuser = '*****';
$dbpass = '*****';

mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);

$sql = 'SELECT t.*, p.*, pp.*
        FROM thread AS t, post as p, postparsed as pp
        WHERE t.forumid = 4 AND p.postid = t.firstpostid AND p.postid = pp.postid
        ORDER BY t.firstpostid DESC 
        LIMIT 5';
$sqlresult = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($sqlresult);

while ($row = mysql_fetch_array($sqlresult))
{
  $subject = $row['title'];
  $poster = $row['username'];
  $posterid = $row['userid'];
  $time = date("D, M j, Y", $row['dateline']);
  $replies = $row['replycount'];
  $id = $row['threadid'];
  $text = $row['pagetext_html'];
  
  if ($replies == 1)
    $replytext = 'reply';
  else
    $replytext = 'replies';
  
  echo "<b>$subject</b>";
  
  echo '<br>';
  
  echo '<font style="font-size: 8pt;">';
  echo "Posted by <a href=\"forums/member.php?u=$posterid\">$poster</a> on $time (<a href=\"forums/showthread.php?t=$id\">$replies $replytext</a>)";
  echo '</font>';
  
  echo '<br><br>';
  
  echo $text;
}
?>

any php/vbulletin gurus that can give me a hand? im just trying to display posts as news on my home page...the news forumid is 4...

Opserty 04-03-2008 08:11 AM

From your query remove: "AND p.postid = pp.postid" does it work then?

Marco van Herwaarden 04-03-2008 08:41 AM

I would start by joining the secondary tables using a LEFT JOIN. If a post has not been parsed yet, then the whole post will not show using your query.


All times are GMT. The time now is 03:57 PM.

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.00934 seconds
  • Memory Usage 1,716KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete