View Full Version : querry for secondary usergroups??
Dankness
02-16-2007, 10:25 AM
Hello i have been tryin to figure out the proper operator to modify all users in a secondary user group. Which the table row would be
TABLE_PREFIX . 'user where membergroupids = 'is this possible?';
Basicly, i just need a method to check if say #1 is inside of the array stored in membergroupids.
Thanks
Shawn
Marco van Herwaarden
02-16-2007, 11:57 AM
Check the MySQL function FIND_IN_SET()
http://dev.mysql.com/doc/refman/4.1/en/string-functions.html
Dankness
02-16-2007, 08:53 PM
Check the MySQL function FIND_IN_SET()
http://dev.mysql.com/doc/refman/4.1/en/string-functions.html
ok thank you for the tip, i have figured some of this out when i run the following querry in phpWebAdmin then it lists what im looking for.
select * from vb_user where FIND_IN_SET ( '6', membergroupids ) > 0";
but when i use it in a php querry then it gives a invalid sql syntanx
$db->query("select * from ".TABLE_PREFIX."user where FIND_IN_SET ( '" . $_POST['usergroup'] . "', membergroupids ) > 0");
EDIT SOLVED:
After playing around with it for awhile i found this which works
$db->query_read("SELECT * FROM ".TABLE_PREFIX."user as a WHERE FIND_IN_SET('{$_POST['usergroup']}', a.membergroupids) ");
Marco van Herwaarden
02-17-2007, 06:12 AM
I hope you are not planning to use that query like this in your final code?
Never use unsanitised variables in a query (like $_POST).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.