billhobbs Posted September 25, 2010 Share Posted September 25, 2010 I'm not sure how to approach this but here is my problem. I'm using a sql statement that counts the number of users in the database. I've created a session variable named $MerchantCount and then I need to multiple that number by this scheme 0-9 Needs to multiple by 2.5 10-19 Needs to multiple by 5.0 20 and up needs to multiple by 7.5 How would I do this? Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/214383-multiple-by-count-and-session-variable/ Share on other sites More sharing options...
PaulRyan Posted September 25, 2010 Share Posted September 25, 2010 So you are counting the number of users, and then wanting to muliply by a preset number. This can be done the following way, may not be the shortest method though... <?php if($MerchantCount <= '9') { $mutliplier = '2.5'; } else if($MerchantCount > '9' && $MerchantCount <= '19') { $mutliplier = '5.0'; } else { $mutliplier = '7.5'; } echo $mutliplier; ?> Then you can use $mulitplier to do any calculation you need to and it will be within your scheme. Tell me how it goes bud. Regards, Paul. Quote Link to comment https://forums.phpfreaks.com/topic/214383-multiple-by-count-and-session-variable/#findComment-1115602 Share on other sites More sharing options...
billhobbs Posted September 25, 2010 Author Share Posted September 25, 2010 That was perfect. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/214383-multiple-by-count-and-session-variable/#findComment-1115618 Share on other sites More sharing options...
PaulRyan Posted September 25, 2010 Share Posted September 25, 2010 No problem bud. Quote Link to comment https://forums.phpfreaks.com/topic/214383-multiple-by-count-and-session-variable/#findComment-1115619 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.