vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Display database information (https://vborg.vbsupport.ru/showthread.php?t=232043)

051119 01-03-2010 03:18 PM

Display database information
 
I have the SQL query
PHP Code:

SELECT vb_user.usernamevb_userfield.field14 FROM vb_userfield
JOIN vb_user ON vb_user
.userid vb_userfield.userid
ORDER BY vb_userfield
.field14 DESC 

Can anyone advise how I can get the output of this to appear on a vB powered page?

Lynne 01-03-2010 03:26 PM

Try looking in any vbulletin php file. This sort of thing is done all the time. Just take a look at the index.php file and how forumusers are defined, or the search.php file and how threads or posts are defined.

051119 01-03-2010 04:21 PM

Thanks for the reply.

I've added
PHP Code:

$mileage2010 $db->query_read_slave("SELECT vb_user.username, vb_userfield.field14 FROM vb_userfield
JOIN vb_user ON vb_user.userid = vb_userfield.userid
ORDER BY vb_userfield.field14 desc"
); 

and also put $mileage2010 onto my page, but nothing is showing!

Lynne 01-03-2010 07:29 PM

All you've done there is get the pointer. You then need to actually access the data like so:
PHP Code:

while ($mileage $db->fetch_array($mileage2010))
{
$username $milieage['username'];
// and then spit it out in a template each time you go through the loop



Mythotical 01-06-2010 10:21 PM

Also change that from $db->query_read_slave to $db->query_read, you only use query_read_slave when you have more than 1 query running together.

051119 02-21-2010 09:14 PM

I'm really sorry, I've been working on this for a while now and really confused by what you mean when you say ''All you've done there is get the pointer. You then need to actually access the data like so''

Lynne 02-21-2010 09:21 PM

I showed you an example. Doing a select just finds the data (gets a pointer to it), then you need to actually fetch it for use with the fetch_array statement. vB does have a shortcut if you are only fetching one line, and that is instead of saying query_read (or query_read_slave), to just say query_first. If you use that, then you do not have to fetch the data afterwards. It would be available in the array you assigned it to - so $mileage2010['username']


All times are GMT. The time now is 05:04 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.03134 seconds
  • Memory Usage 1,721KB
  • 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
  • (3)bbcode_php_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