vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   select and parse for news page (https://vborg.vbsupport.ru/showthread.php?t=187232)

DionDev 08-04-2008 08:43 PM

select and parse for news page
 
this is some code i use to display topics from a specific forum for a "news" page...
PHP Code:

$sql 'SELECT post.pagetext, thread.*
        FROM post AS post, thread AS thread
        LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
        WHERE FIND_IN_SET(4, forum.parentlist) AND post.postid = thread.firstpostid
        ORDER BY thread.dateline DESC
        LIMIT 5'
;

$sqlresult mysql_query($sql) or die(mysql_error());

while (
$row mysql_fetch_array($sqlresult))
{
  
$subject $row['title'];
  
$poster $row['postusername'];
  
$posterid $row['postuserid'];
  
$time date("D, M j, Y"$row['dateline']);
  
$replies $row['replycount'];
  
$id $row['threadid'];
  
$text $parser->do_parse($row['pagetext'], truetruetruetruetruefalse);
  
  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;


this workd, but can anyone think of a more efficient way of doing this?

Dismounted 08-05-2008 10:58 AM

If it's not a frequently posted in forum (ie. not as regular as discussion forum), then you could store it in the datastore, and only update it when it is posted in.


All times are GMT. The time now is 03:54 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.01481 seconds
  • Memory Usage 1,722KB
  • 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
  • (2)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