vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   MySQL, PHP and new posts? (https://vborg.vbsupport.ru/showthread.php?t=181830)

shunga 06-12-2008 10:39 PM

Quote:

Originally Posted by Dismounted (Post 1547322)
The number in the link to threads is the ID ;).

I realised my mistake after I posted.

I need to do a second query to get the thread text, but without knowing the names of everything I'm struggling. I've searched through Google and through the owners area without any luck in the search for documentation.

Any online source for the MySQL table layout?

--------------- Added [DATE]1213317483[/DATE] at [TIME]1213317483[/TIME] ---------------

As always, as soon as you ask for something, you find it. ;)

I have it all working fine now. Thanks for all your help. :)

marin 06-20-2008 09:17 AM

Hey
It would be great if you post the code here. I've been looking for this for a long time!
Thanks, Marin

shunga 06-20-2008 11:58 AM

The code is below. I'm sure there are much more elegant methods, but it works:

Code:

$result = mysql_query("SELECT postid, username, userid, dateline, pagetext, threadid
FROM post
WHERE visible = 1
ORDER BY dateline DESC
LIMIT 10")
        or die('I cannot select from the database because: ' . mysql_error());

while($rows = mysql_fetch_assoc($result)) {
  $result_thread = mysql_query("SELECT title,forumid FROM thread WHERE threadid='" . $rows['threadid'] . "'")
        or die('I cannot select from the database because: ' . mysql_error());
$rows_thread = mysql_fetch_assoc($result_thread);

$result_forum = mysql_query("SELECT title FROM forum WHERE forumid='" . $rows_thread['forumid'] . "'")
        or die('I cannot select from the database because: ' . mysql_error());
$rows_forum = mysql_fetch_assoc($result_forum);

// basic variables required to output latest posts
print $rows_thread['forumid'], $rows_forum['title'], $rows['threadid'], $rows_thread['title'], $rows['pagetext'], $rows['username'], $rows['dateline'];
}

I hope that's helpful.


All times are GMT. The time now is 01:07 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.01202 seconds
  • Memory Usage 1,725KB
  • 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_code_printable
  • (1)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
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete