vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help with a query :( (https://vborg.vbsupport.ru/showthread.php?t=50279)

N9ne 03-16-2003 02:49 PM

Help with a query :(
 
What is the query to run (I'm guessing involves LEFT JOIN), to get the required information to display the title of the styleid a user is using?

Is a while() function required too? If so, what do I place? Are we fetching an array?

filburt1 03-16-2003 02:51 PM

Code:

mysql> SELECT s.title FROM user u, style s WHERE u.userid = 1 AND s.styleid = u.styleid;
+------------+
| title      |
+------------+
| Default vB |
+------------+
1 row in set (0.26 sec)


N9ne 03-16-2003 03:12 PM

That query just gives me errors, what's the query I could place in a vB file?

$style=$DB_site->query("SELECT s.title FROM user u, style s WHERE u.userid = '$userinfo[userid]' AND s.styleid = u.styleid");

That also doesn't work, I'm not sure what to do, I just want to be able to put a variable in a template, and it output not the user viewing the page, but users' style sets...it's for the memberlist..

N9ne 03-16-2003 03:37 PM

ok I figured it out for myself, I used this:

PHP Code:

    $style $DB_site->query("SELECT title FROM user u, style s WHERE u.userid = '$userinfo[userid]' AND s.styleid = u.styleid");
        while (
$styleinfo=$DB_site->fetch_array($style)) {
          
$styleinfouser=$styleinfo[title];
        } 


filburt1 03-16-2003 03:38 PM

Make sure $userinfo['userid'] (BTW, /me smacks N9ne for using constants instead of strings in array keys) is set correctly. The query works as you can see.

N9ne 03-16-2003 04:13 PM

ok there must be something wrong with the code, because:

I have 3 users on my localhost (I just created some random users), and...

It shows nothing for me...

For the user below me in the memberlist, it shows the style I'm using...

For the 3rd user, it shows the second style on the board (there's only 2), even though he's using the first style...

I'm clueless, i'm about to give up this, I could've sworn something with LEFT JOIN must be done for this to work properly...

filburt1 03-16-2003 04:24 PM

Check their styleids and that they're all 1 (i.e., not 0).

N9ne 03-16-2003 04:29 PM

All styleids are correct.


All times are GMT. The time now is 06:41 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.01051 seconds
  • Memory Usage 1,723KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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