vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP implode is exploding my mind!!!!!! (https://vborg.vbsupport.ru/showthread.php?t=124147)

Antivirus 08-16-2006 07:45 PM

PHP implode is exploding my mind!!!!!!
 
What i want to do: pull all forum ids having a specific parent forum, and place them in a string ( $newsfeedforumids ) so they can be added to end of external.php lilke this:

PHP Code:

$vboptions[bburl]/external.php?type=rss2&forumids=$newsfeedforumids 


My query:
PHP Code:

// set parent forum id
$parentid 6;

// get child forumids for parent
$forumids_q $db->query_read("
    SELECT forumid 
    FROM " 
TABLE_PREFIX "forum 
    WHERE parentid = 
$parentid
"
);
$forumids mysql_fetch_array($forumids_q);
$newsfeedforumids implode(","$forumids); 

Then I plug the $newsfeedforumids onto the end of external.php llike so:
Code:

<a href="$vboptions[bburl]/external.php?type=rss2&amp;forumids=$newsfeedforumids" target="_blank">Click for Feed</a>
however there's 14 different forum ids supposed to be queried, and all i get attached to the end of the url is the first result as so:
bburl/external.php?type=rss2&amp;forumids=7,7

What am i doing wrong?

Paul M 08-16-2006 09:14 PM

You are misunderstanding what mysql_fetch_array() does. This fetches one row of the result set as an array, not the entire result set. You need a 'while' loop to fetch the results row by row to build your array of forumids.

Antivirus 08-17-2006 05:34 PM

thanks Paul, this worked for me:

PHP Code:

$newsfids_q $db->query_read
    
("
    SELECT forumid FROM " 
TABLE_PREFIX "forum 
    WHERE (parentid = " 
$news_setup['artist_news_parent_forum_id'] . 
    OR forumid = " 
$news_setup['eclipse_news_forum_id'] . ")
    "
);
while (
$newsfid mysql_fetch_array($newsfids_q))
{
    
$forumids .= $newsfid['forumid'] . "," ;
}
$newsfeedforumids $forumids

would there have been a better way to do it than above?

Paul M 08-17-2006 06:15 PM

Quote:

Originally Posted by Antivirus
would there have been a better way to do it than above?

Not really.

Antivirus 08-17-2006 06:36 PM

cool, thanks again for the help!

Code Monkey 08-17-2006 06:55 PM

Quote:

Originally Posted by Antivirus
thanks Paul, this worked for me:

PHP Code:

$newsfids_q $db->query_read
    
("
    SELECT forumid FROM " 
TABLE_PREFIX "forum 
    WHERE (parentid = " 
$news_setup['artist_news_parent_forum_id'] . 
    OR forumid = " 
$news_setup['eclipse_news_forum_id'] . ")
    "
);
while (
$newsfid mysql_fetch_array($newsfids_q))
{
    
$forumids .= $newsfid['forumid'] . "," ;
}
$newsfeedforumids $forumids

would there have been a better way to do it than above?

Yes there would be if you want to be fully integrated. Use vBulletins $db->fetch_array. ;)

PHP Code:

$newsfids_q $db->query_read
    
("
    SELECT forumid FROM " 
TABLE_PREFIX "forum 
    WHERE (parentid = " 
$news_setup['artist_news_parent_forum_id'] . 
    OR forumid = " 
$news_setup['eclipse_news_forum_id'] . ")
    "
);
while (
$newsfid $db->fetch_array($newsfids_q))
{
    
$forumids .= $newsfid['forumid'] . "," ;
}
$newsfeedforumids $forumids


Antivirus 08-23-2006 09:34 PM

good point Codemonkey, thanks!


All times are GMT. The time now is 05:02 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.01214 seconds
  • Memory Usage 1,754KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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