Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 08-03-2002, 12:35 PM
Keith Keith is offline
 
Join Date: Jan 2002
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Display MySQL Query result

This is my query

Code:
$boatbrands=$DB_site->query('select count(*)
AS countboats, field6 as boatbrands FROM userfield 
WHERE field6 <> "n/a" AND field6 <> "n" AND field6 <> "none" 
AND field6 <> "NA"
GROUP by field6
ORDER BY 1 DESC LIMIT 10');
Now how to display the results of this query? I've added an eval dooutput to a template at the bottom, but the results are showing up as the word "Array" when I use "query_first, and "resource ID #38" when I use "query". I don't think I'm supposed to use query_first because that will only return the first row.

The result is supposed to be 10 rows of 2 columns worth of data, but I can't figure out what I'm doing wrong here.
Reply With Quote
  #2  
Old 08-03-2002, 12:52 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$boatbrands=$DB_site->query('select count(*)
AS countboats, field6 as boatbrands FROM userfield 
WHERE field6 <> "n/a" AND field6 <> "n" AND field6 <> "none" 
AND field6 <> "NA"
GROUP by field6
ORDER BY 1 DESC LIMIT 10'
);
while(
$boatbrand=$DB_site->fetch_array($boatbrands)) {
  
// enter here your output orders/ template bits or something like that

Reply With Quote
  #3  
Old 08-03-2002, 01:33 PM
Keith Keith is offline
 
Join Date: Jan 2002
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been using some examples in other php files and the PHP man to learn the output piece, but even though I think I've got that right, I'm still getting the Resource ID #38 error in the output. Where can I find what the error is really trying to tell me?

Here's what I'm using for the output
Code:
while($boatbrand=$DB_site->fetch_array($boatbrands)) {
	
$boatbrand=$boatbrand["$boatbrands"];

}
Reply With Quote
  #4  
Old 08-03-2002, 01:37 PM
Keith Keith is offline
 
Join Date: Jan 2002
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Forgot to say "thanks for the reply" in my other message. Here''s the whole piece which may help.

Code:
// ############     How many of each brand of boats

$boatbrands=$DB_site->query('select count(*)AS countboats, field6 as boatbrands FROM userfield 
WHERE field6 <> "n/a" AND field6 <> "n" AND field6 <> "none" AND field6 <> "NA"
GROUP by field6
ORDER BY 1 DESC LIMIT 10');

while($boatbrand=$DB_site->fetch_array($boatbrands)) {
	$boatbrands=$boatbrands["boatbrands"];

}


eval("dooutput(\"".gettemplate("boatstats_stats")."\");");

}
The template has the variable $boatbrands
Reply With Quote
  #5  
Old 08-03-2002, 01:42 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

use $boatbits in your boatstats_stats template

then change the code to:
[code]while($boatbrand=$DB_site->fetch_array($boatbrands)) {
eval("\$boatbits .= \"".gettemplate("boatbit")."\";");

}[/php]

then create a new template called boatbit and there use the variable $boatbrand
Reply With Quote
  #6  
Old 08-03-2002, 02:15 PM
Keith Keith is offline
 
Join Date: Jan 2002
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again Xenon. The result is simply the word ARRAY.

I'll keep tweaking.
Reply With Quote
  #7  
Old 08-03-2002, 02:59 PM
Keith Keith is offline
 
Join Date: Jan 2002
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

GOT IT!!!

Xenon, many many thanks my friend. I was finally able to get it to display. I was, of course, doing a lot of things wrong and I sincerely appreciate your help.

Here was went into the boatbit template:
Code:
<tr align='center'>
	<td bgcolor='{firstaltcolor}'>$boatbrand[countboats] - $boatbrand[boatbrands]</td>
	</tr>
Reply With Quote
  #8  
Old 08-03-2002, 11:15 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default


you're welcome
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:10 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.04323 seconds
  • Memory Usage 2,223KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete