alwaysme Posted June 7, 2008 Share Posted June 7, 2008 hello, i have a script installed that only allows a particular group id to do something if($op=='message' && $group_id==3) how can i make it so that group ID 3,4 can have access also? and lets say 3,4,7 ? thanks so much Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/ Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 $group_id >= 3 if you want everything 3++ or $group_id >= 3 && $group_id <= 7 if you want it to be in that range. or for those specific 3 numbers: $blah = array(3, 4, 7); if ($op=='message' && in_array($group_id, $blah)) { ... } Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-559932 Share on other sites More sharing options...
alwaysme Posted June 7, 2008 Author Share Posted June 7, 2008 hello, thanks for your quick response. but u are not done with me... what do i place inside the { ... } ? lets say i only want it for group 3 and 5 and thats it (no 4)? what would it be? and im not sure what the $blah function is...sorry this is extremely amatuer q's.. /* * Send a notification to the user who applied */ if($op=='message' && $group_id==3) { Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560005 Share on other sites More sharing options...
gli Posted June 7, 2008 Share Posted June 7, 2008 IN { } you execute your commands. $blah is variable for array, in array there you can place integers which in this case are that acces levels, if you want group 3 and 5 then you need make < ?php $blah = array(3, 5) ?> thats all i know. if you dont understand arrays you can find at google, arrays are simple. sorry for my bad English Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560043 Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 The { ... } is what is normally in the IF statement. We don't know what you want in there, lol. And $blah is just a variable. He's using it in the in_array() function to check if their level is in the ones specified in the array. Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560046 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 hello, thanks for your quick response. but u are not done with me... what do i place inside the { ... } ? You put your code in there. Your condition checks if user meets level requirements, if they do, then...put the code in there. lets say i only want it for group 3 and 5 and thats it (no 4)? what would it be? and im not sure what the $blah function is...sorry this is extremely amatuer q's.. Then you would use option #3, the one where I said "..with specific numbers" $blah = array(3, 4, 7); if ($op=='message' && in_array($group_id, $blah)) { ... } If you just wnat 3 and 5 then change the numbers in the array(..) to just 3 and 5. Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560060 Share on other sites More sharing options...
alwaysme Posted June 8, 2008 Author Share Posted June 8, 2008 thanks guys, but this is getting too complicated. when i make changes im getting a blank page... can we work with larger junks of code or its not allowed here?? for example...the script im using sends an email to the admin once someone fills out a complete form /* confirmation email to staff */ list($body,$from,$subject,$html,$reply_to,$return_path)=sqlget(" select body,from_addr,subject,html,reply_to,return_path from system_emails where email_id=5 and active=1"); $body=str_replace("%jobno%",$ref,$body); $html=str_replace("%jobno%",$ref,$html); $subject=str_replace("%jobno%",$ref,$subject); $body=str_replace("%link%","$server_name2/admin/resumes.php?op=edit&id=$resume_id",$body); $html=str_replace("%link%","<a href=$server_name2/admin/resumes.php?op=edit&id=$resume_id>$server_name2/admin/resumes.php?op=edit&id=$resume_id</a>",$html); if(!$from) $from="noreply@$email_domain"; $q=sqlquery("select distinct email from user,user_group where user.user_id=user_group.user_id and group_id=3 and notify=1 and email<>''"); <-------------- this line?? while(list($admin_email)=sqlfetchrow($q)) { $msg = new message($from,$admin_email,$subject); $msg->body($body); if($reply_to) $msg->headers.="\nReply-To: $reply_to"; if($return_path) $msg->headers.="\nReturn-Path: $return_path"; if($html) $msg->body($html,'text/html'); if($body) $msg->send(); } } ob_end_clean(); if($job2) header("Location: jobsearch.php?job2=$job2".($f_login?"":"&resume_id=$resume_id"). "&msg=".urlencode($msg_resume_register[LOGGED])); else header("Location: jobsearch.php?msg=".urlencode($msg_resume_register[sUCCESS])); exit(); } the code above dispatchs an email to group "3" which is adminstrators...id like that email to also go to group "5" which are sub-admins...can you please guide me with this? i appreciate this. If anyone needs help with logo design i am happy to assist.. thank u Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560491 Share on other sites More sharing options...
.josh Posted June 8, 2008 Share Posted June 8, 2008 I've already told you twice how to do it. Use an array and do a condition to check if the user level number is in the array. I've provided the code for you, twice. I see conditions all over your script, so you seem to know what those are about. What exactly are you having trouble with, as far as making a simple array and checking if your number is in_array(..)? No offense, but I really don't see how I can make it any simpler than giving you a working example..which I already did. I mean, I see you using list() which is like, 1 step away from arrays. Or maybe a cousin once removed, or something. Do you want me to write your code for you? I'm available, for a modest fee. Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560527 Share on other sites More sharing options...
alwaysme Posted June 8, 2008 Author Share Posted June 8, 2008 Hello, i totally understand the stance u are taking with this. I'd have a more upset approach if i were in your place also..but please understand i did not write any of that code. Its a ready made script i want to use for my website. When someone fills in a form they get an email i tried hard just searching for that line of code that is responsible for dispatching the email. I tried applying your code but i do get errors... i know you offered solutions but i am having trouble applying them to this code. kindly help me fix this $q=sqlquery("select distinct email from user,user_group where user.user_id=user_group.user_id and group_id=3 && and notify=1 and email<>''"); Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-560629 Share on other sites More sharing options...
alwaysme Posted June 9, 2008 Author Share Posted June 9, 2008 anybody find a resolution for me? /* confirmation email to staff */ list($body,$from,$subject,$html,$reply_to,$return_path)=sqlget(" select body,from_addr,subject,html,reply_to,return_path from system_emails where email_id=5 and active=1"); $body=str_replace("%jobno%",$ref,$body); $html=str_replace("%jobno%",$ref,$html); $subject=str_replace("%jobno%",$ref,$subject); $body=str_replace("%link%","$server_name2/admin/resumes.php?op=edit&id=$resume_id",$body); $html=str_replace("%link%","<a href=$server_name2/admin/resumes.php?op=edit&id=$resume_id>$server_name2/admin/resumes.php?op=edit&id=$resume_id</a>",$html); if(!$from) $from="noreply@$email_domain"; $q=sqlquery("select distinct email from user,user_group where user.user_id=user_group.user_id and group_id=3 and notify=1 and email<>''"); <-------------- this line?? while(list($admin_email)=sqlfetchrow($q)) { i added $myblah = array(3, 5); under this line $from="noreply@$email_domain"; and then i get stuck adding your changes to this group_id=3 and notify=1 and email<>''"); ?? againi want it to send email to also group id 5 instead of 3 only.... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-561011 Share on other sites More sharing options...
miseleigh Posted June 9, 2008 Share Posted June 9, 2008 Mentioning that it's an SQL query would have made a big difference here. $q=sqlquery("select distinct email from user,user_group where user.user_id=user_group.user_id and (group_id=3 or group_id=5) and notify=1 and email<>''"); Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-561087 Share on other sites More sharing options...
alwaysme Posted June 11, 2008 Author Share Posted June 11, 2008 thanks...sorry for the delay i had a extreme fever.. also it worked...but the php section did not (in another file)...the sql part worked well Quote Link to comment https://forums.phpfreaks.com/topic/109157-adding-more-than-one-id-one-line/#findComment-563314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.