  # imgrooot

Members

383

1

## Everything posted by imgrooot

1. I didn't know a database could hold billions of rows and still work fine. Good to know. That answers my question. Of course I was giving an extreme example when I said millions of rows. But if it can handle that, then great. I was a little hesitant before because I never had that many records stored in a table before.
2. I have a table like this. investment_id | investor_id | deposit | Date | Status I will be depositing funds into this table. For eg. If I am paying out 1000 investors at a time, 1000 rows will be added to this table. I might do this 100 times a day. That's 100,000 rows added in a day. Each deposit I do will be unique, even though it might be going to the same person multiple times. This could end up with million of rows. I am wondering if this is the correct way to do this or is there a better method?
3. Your right. The results for my second and third calculations would be what you wrote. My mistake what I wrote in the comment part of it. But the math works out with the code itself. Your example is an interesting way to solve this problem. And yes now that you mention it, it is more like shares than commissions. I will try it out as well.
4. Alright so I think I have it figured out. It's rather simple. \$total_amount = 100; // 100 dollars \$total_members = 250; // 250 members \$total_commission = 60; // 60% commission \$get_percent = (\$total_commission / 100) * \$total_amount; \$new_total = \$get_percent / \$total_members; // \$60 / 250 = 0.24 per user. This is what I was missing before. // Since above is based on 60%, I still have 30% and 10% left. Below are these examples. \$total_amount = 100; // 100 dollars \$total_members = 50; // 50 members for this example, just to vary it up. \$total_commission = 30; // 30% commission \$get_percent = (\$total_commission / 100) * \$total_amount; \$new_total = \$get_percent / \$total_members; // \$30 / 250 = 0.12 per user. \$total_amount = 100; // 100 dollars \$total_members = 20; // 20 members for this example, just to vary it up. \$total_commission = 10; // 10% commission \$get_percent = (\$total_commission / 100) * \$total_amount; \$new_total = \$get_percent / \$total_members; // \$10 / 250 = 0.04 per user. \$60(60%), \$30(30%), \$10(10%) sum up to \$100. No matter how many users are in each percentage pool, it'll always sum up to that exact total.
5. Alright so based on what you said, here is the new example. \$total_amount = 100; // 100 dollars \$total_members = 250; // 250 members \$total_commission = 60; // 60% commission \$new_commission = \$total_commission / 100; // this would return 0.6 \$new_members = 1 / \$total_members; // this would return 0.004 \$userPercentage = \$new_commission * \$new_members; // 0.6 * 0.004 = 0.0024 \$userShare = \$userPercentage * \$total_amount; // 0.0024 * 100 = 0.24 \$new_total = \$userShare * \$total_members; // 0.24 x 250 = 60 That returns a total of 60 for each user. That is technically correct. But remember there are total of 250 users. That's \$60 x 250 = \$15,000. That not what I am looking for. I am looking for all 250 users' amount to sum up to \$100 in total. Normally I can 100/250 and it'll return \$0.4 for each user. But since each user has a different percentage, each of them is going to have different values that add up to \$100. Please let me know if I am making sense.
6. I should also mention that the example I share and the example you edited have are for 3 users only that equals to \$100. I will be using this formula in a foreach loop. So if I have more the 4 users, which I do, their total sum is greater than \$100, which is not what I want. For eg. Here's the for each loop. \$total_members = 250; foreach(\$result as \$row) { \$commission = \$row['commission']; // This commission could be 10%, 30%, 60%; \$amount = \$row['amount']; \$new_commission = \$commission / 100; \$userPercentage = 0.1 * \$new_commission; \$total = \$amount; \$userShare = \$userPercentage * \$total; \$new_total = \$userShare * \$total_members; echo \$new_total; }
7. So what if I have 250 users? What would 0.1 look like in this line? Is it 1/10th of 250, which is 25? \$userPercentage = 0.1 * 0.6;
8. Actually I realized something. Your method would normally work but not with what I am trying to do. For eg. Say I have 30 users. 10 users get 10% 10 users get 30% 10 users get 60% Total of 30 users with their own percentages. Using your method, it would look like this. \$userPercentage = 0.1; // 10% \$total = 100; \$userShare = \$userPercentage * \$total; // 0.05 * 100 = 10 \$new_total = \$userShare * 10; // 10 being the amount of users. This totals \$100. \$userPercentage = 0.3; // 30% \$total = 100; \$userShare = \$userPercentage * \$total; // 0.3 * 100 = 30 \$new_total = \$userShare * 10; // 10 being the amount of users. This totals \$300. \$userPercentage = 0.6; // 60% \$total = 100; \$userShare = \$userPercentage * \$total; // 0.6 * 100 = 60 \$new_total = \$userShare * 10; // 10 being the amount of users. This totals \$600. All totaling to \$1,000 for 30 users. That's not what I want. I want to have all 30 users' total come to the original amount, which is \$100, not \$1,000.
9. That makes sense. Thank you.
10. My question may be a little confusing so I will give you another example. Above I gave you an example of 5 users only. This could easily be 100 or 1000 users. So If I have 100 users with individual percentage of 5%,10%,15% and the total give away amount is \$100, how would you divide the \$100 among the 100 users?
11. Say I have 5 users. Each user will receive their payment based on their individual percentage. For eg. User 1: 5% User 2: 10% User 3: 15% User 4: 15% User 5: 5% Now say I have a total of \$100. I want to divide the \$100 among the 5 users. But the users with higher % will receive a higher amount than the the ones with lower %. How would I calculate this?
12. My code works but so does your code. And I must admit your code is far more simpler and cleaner. I will use your example. Thanks.
13. Well since no one else has anything to add. Here's my full answer to the original problem. \$api_amount = array(); \$api_recp = array(); \$api_trans_id = array(); \$api_sender_id = array(); foreach(\$get_address->data->txs as \$tx){ \$api_amount[] = \$tx->amounts_received->amount; \$api_recp[] = \$tx->amounts_received->recipient; \$api_trans_id[] = \$tx->txid; \$api_sender_id[] = \$tx->senders; } \$post_transid = \$_POST['trans-id']; // example 1 if(in_array(\$post_transid, \$api_trans_id)) { echo 'yes'; } else { echo 'no'; } // example 2 if(in_array('0.00400000', \$api_amount)) { echo 'yes'; } else { echo 'no'; }
14. I tried it as \$api_sender_id[] = \$tx->senders; And it seems to work. So far so good. Please let me know if anything I've said is incorrect.
15. Alright so I think I figured it out. Using "kicken"'s foreach loop, I need to turn the loop variables into an array and access them outside the loop like this. \$api_amount = array(); \$api_recp = array(); \$api_trans_id = array(); \$api_sender_id = array(); foreach(\$get_address->data->txs as \$tx){ \$api_amount[] = \$tx->amounts_received->amount; \$api_recp[] = \$tx->amounts_received->recipient; \$api_trans_id[] = \$tx->txid; \$api_sender_id[] = \$tx->senders; } \$post_transid = \$_POST['trans-id']; if(in_array(\$post_transid, \$api_trans_id)) { echo 'yes'; } else { echo 'no'; } if(in_array('0.00400000', \$api_amount)) { echo 'yes'; } else { echo 'no'; } The above works. One thing that doesn't work is the "\$api_sender_id". I realized why. This is how it looks in json. If you look closley you will notice the value of "senders" is directly after the bracket ([). The others don't have that. So how do I access this "senders" value? status" : "success", "data" : { "network" : "BTC", "txs" : [ { "txid" : "71d9afcc73da63c45674088411460116cfefe324cc7a6f5fcb267d9f584adf73", "from_green_address" : false, "time" : 1496877627, "confirmations" : 3080, "amounts_received" : [ { "recipient" : "4QFaAYB4r8sk7MG3beb7yY4R21t9JrnMwK", "amount" : "0.00200000" } ], "senders" : [ "6EqvPUTwjUuon6c2a6YxBreJtBkkZD5fsp" ], "confidence" : 1.0, "propagated_by_nodes" : null } ] } Edit: Sorry for the shit code paste. It shows in fine in the code editor but it for some reason it shows outside of it after I save it.
16. I'm assuming you mean check if it's true or not inside the foreach loop like this? foreach (\$get_address->data->txs as \$tx){ \$api_amount = \$tx->amounts_received->amount; \$api_recp = \$tx->amounts_received->recipient; \$api_trans_id = \$tx->txid; \$api_sender_id = \$tx->senders; if(\$api_trans_id == \$_POST['trans-id']) { echo 'Success'; } else { echo 'Fail.'; } } If so then I get the "Fail" error. It's shown repeated multiple times.
18. I am using a phpmailer to send emails to users. I noticed that it only sends email if I am calling it from a page in a root directory. Say I am sending an email from contact.php and it's inside a sub folder/directory instead of the root, it won't email out. Setup is like this. include_once '../phpmailer/class.phpmailer.php'; \$mail = new PHPMailer; \$mail->IsSMTP(); // Set mailer to use SMTP \$mail->Host = '127.0.01'; // Specify main and backup server \$mail->From = 'hello@myemail.com'; \$mail->FromName = 'Myname'; \$mail->AddAddress(\$user_email); // Name is optional \$mail->WordWrap = 50; // Set word wrap to 50 characters \$mail->IsHTML(true); // Set email format to HTML \$mail->Subject = 'Your account has been deleted!'; \$mail->Body = "Hello {\$username},<br><br> We are letting you know that your account has been deleted"; if(!\$mail->Send()) { \$errors[] = \$mail->ErrorInfo; } else { if(empty(\$errors)) { \$db->commit(); \$success = 'Email sent.'; } else { \$db->rollBack(); } }
19. Say I have directory setup like this. core/ includes/ snippets/ template.php js/ index.php Say in the index.php file, I have a file path like this " include 'snippets/template.php'; ". It works. Or say If I am in template.php and I have a file path like this " include '../index.php'; ". It works as well. I am wondering if there is a more global method to this so I don't have to worry about when to use "../" or not. It becomes hectic if there are a lot of includes and/or links.
20. I see your point. I will sure to relay your concerns to the client.
21. You're second statement could be one of the ways to achieve this goal.
22. That's all he's trying to achieve. The output is the encrypted password. He basically wants users to have a complex password that they can use for their social media accounts. For eg. User inputs "johnsmith", the output will be "Rju9f3j5?10w3j81". The user can use this output password to register for say Facebook. The user also knows that if they ever forget the output password but knows the original input, he can go back to the site, input "johnsmith" again and receive the exact same output as before. That's his goal.
23. Alright so here's the new info. The new encryption will be like a password. User inputs text into a textfield and hits submit. It will return a string of 16 digits with uppercase letter, lowercase letter, a number and a special character. There will be no decryption or saving it in the database. Also the client wants it so that it's not a random string of numbers for the same word. So if the input is "johnsmith", then it will return the same string no matter how many times it has been submitted. Can that be done?
24. I'm getting the details tomorrow. I'll let you know.
×
×
• Create New...