vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need Your help with query_read (https://vborg.vbsupport.ru/showthread.php?t=321331)

madzat 01-02-2016 10:49 PM

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

Dave 01-02-2016 11:24 PM

PHP Code:

SELECT user.usernameuser.field7 FROM ". TABLE_PREFIX ."user LEFT JOIN mo_userfield ON(mo_user.userid=mo_userfield.useridWHERE user.usergroupid 13 


madzat 01-03-2016 01:18 AM

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

Dave 01-03-2016 01:47 PM

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


madzat 01-03-2016 02:42 PM

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"); 


Elite_360_ 01-04-2016 02:03 AM

PHP Code:


$db
->query_write("INSERT INTO " TABLE_PREFIX "spmembers
        (spusername)
    VALUES
        ('" 
$db->escape_string($array2['field7']) . "')
"
); 



All times are GMT. The time now is 02:29 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.02236 seconds
  • Memory Usage 1,745KB
  • 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
  • (10)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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