Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2016, 10:49 PM
madzat madzat is offline
 
Join Date: Sep 2006
Location: germany
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need Your help with query_read

Hey there, plz i need your help with sql so here my problem i have field7 and i made page for Normal user and super user so all super user is group 13 to read the group im using
PHP Code:
$db->query_read("SELECT username FROM "TABLE_PREFIX ."user WHERE usergroupid = 13"); 
and is working well so my problem now i want to make page for super user using the field7 when i try read
PHP Code:
$db->query_read("SELECT username, field7 FROM "TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.userid)"); 
i get all member list so i want just group 13 if add
PHP Code:
$db->query_read("SELECT username, field7 FROM "TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.userid && usergroupid=13)"); 
is not working any help plz


Thx
Reply With Quote
  #2  
Old 01-02-2016, 11:24 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
SELECT user.usernameuser.field7 FROM ". TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.useridWHERE user.usergroupid 13 
Reply With Quote
Благодарность от:
madzat
  #3  
Old 01-03-2016, 01:18 AM
madzat madzat is offline
 
Join Date: Sep 2006
Location: germany
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thx for your fast replay and is working and plz if any chance to add 2 group in the same time like that for exemple ??
PHP Code:
in_array($bbuserinfo['usergroupid'], array(1312)) 

PHP Code:
SELECT user.usernameuser.field7 FROM ". TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.useridWHERE in_array($bbuserinfo['usergroupid'], array(1312)) 

thx again
Reply With Quote
  #4  
Old 01-03-2016, 01:47 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't use PHP like that in SQL queries.

PHP Code:
SELECT user.usernameuser.field7 FROM ". TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.useridWHERE user.usergroupid IN(13,12
Reply With Quote
Благодарность от:
MarkFL
  #5  
Old 01-03-2016, 02:42 PM
madzat madzat is offline
 
Join Date: Sep 2006
Location: germany
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thx man for your help

--------------- Added [DATE]1451870478[/DATE] at [TIME]1451870478[/TIME] ---------------

Hi all i still have smal problem with sql is here i made new table spmembers and have spusername im using like that and is not working to add all list to sql
PHP Code:
$spmember $db->query_read("SELECT username, field7 FROM "TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.userid) WHERE usergroupid IN(12,13)");

$i=0;
while (
$array2 $db->fetch_array($spmember))
{
    
// Do something with the current row here
    
if($i==0)
    {
        
$res_html.= "<tr><td width='50%' style='color:#e37616;'>".$array2['field7']."</td></tr>";
        
$i++;
    }
    else
    {
        
        
spmember $db->query_write("INSERT INTO " TABLE_PREFIX "spmembers (spusername) VALUES field7");
            
$res_html.= "<tr><td width='50%' style='color:#e37616;'>".$array2['field7']."</td></tr>";

    }
    

i want to add field7 to sql i tested with array not not working and i dont know haw to fix plz any help thx

PHP Code:
spmember $db->query_write("INSERT INTO " TABLE_PREFIX "spmembers (spusername) VALUES field7"); 
Reply With Quote
Благодарность от:
MarkFL
  #6  
Old 01-04-2016, 02:03 AM
Elite_360_'s Avatar
Elite_360_ Elite_360_ is offline
 
Join Date: Nov 2012
Location: New Hampshire
Posts: 518
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:

$db
->query_write("INSERT INTO " TABLE_PREFIX "spmembers
        (spusername)
    VALUES
        ('" 
$db->escape_string($array2['field7']) . "')
"
); 
Reply With Quote
2 благодарности(ей) от:
madzat, MarkFL
Reply


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:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04768 seconds
  • Memory Usage 2,245KB
  • 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
  • (10)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (5)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete