vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Select first 5 database entries based on ID? (https://vborg.vbsupport.ru/showthread.php?t=156949)

amnesia623 09-03-2007 07:04 PM

Select first 5 database entries based on ID?
 
I have a RSS feeds that store the RSS data into the database. There are multiple feeds that are all identified by a feed id. (so cnn.com would be feed 1, tmz.com would be feed 2, etc...)

I want to select the and display the RSS feed on my forums based on the forum ID and have a default for areas that don't have a forum ID specified (ie...forumhome). I am hoping to display 5 results at a time

I am pecking around VB.org and found the

$result= $vbulletin->db->query_read("SELECT `feedID` , `ItemTitle` , `ItemLink`
FROM `feedItems`
WHERE feedID =1
LIMIT 5");

but I am unsure how to go about putting the results from $results into a variable and running a while loop. I also see that $results is a common variable to use, can I use another variable or is $results the best to use for vbulletin apps?

Also - would the code for this be better in a plugin, or called from an external file via plugin?

Thanks!
-------------------------------------------------------------------

OK - I'm trying this but it's not working ...can someone help please?

Code:

$query2 = $vbulletin->db->query_read(
"SELECT feedID , ItemTitle , ItemLink
FROM feedItems
WHERE feedID =1
LIMIT 5");

while ($rssres = $db->fetch_array($query2))
{
$latestrss = $rssres['ItemTitle'] <br />;

}

Nothing show up. The hook location is global start. The tables don't have the vb table prefix attached.
-----------------------------------------------------------------
Code:

    $rss_get = $db->query_read("SELECT * FROM feedItems"); 


while ($subcat = $db->fetch_array($rss_get)) {
      $rss_feed = $subcat["ItemTitle"];

    }

when I put $rss_feed on the navbar template I only get the last record in the feedItems table. How would I go about displaying all the records?
----
ughh......this thing keeps merging my posts....

BartS 09-04-2007 06:48 PM

Change

PHP Code:

$rss_get $db->query_read("SELECT * FROM feedItems");  


while (
$subcat $db->fetch_array($rss_get)) {
      
$rss_feed $subcat["ItemTitle"];

    } 

To:

PHP Code:

$rss_get $db->query_read("SELECT * FROM feedItems");  

$rss_feed '';
while (
$subcat $db->fetch_array($rss_get)) {
      
$rss_feed .= $subcat["ItemTitle"];

    } 


amnesia623 09-04-2007 07:41 PM

sweet - than you very much!

I appreciate it!


All times are GMT. The time now is 08:36 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.01886 seconds
  • Memory Usage 1,719KB
  • 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
  • (2)bbcode_code_printable
  • (2)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