xwishmasterx Posted April 8, 2011 Share Posted April 8, 2011 I am need of some help on how to create a form with multiple receivers between tables. table1.field1 value is 10000 the form should allow a person to enter the id for those members to receive(separated by a comma) and the amount they each receive from table1.field1 then of course add the amount too each members account, and subtract the total from table1.field1 (and of course check if the value is high enough to distribute the desired amount between members. I need a little hand to get started here, so hopefully someone is willing to point me in the right direction Quote Link to comment https://forums.phpfreaks.com/topic/233136-need-help-creating-form-with-multiple-recievers/ Share on other sites More sharing options...
spiderwell Posted April 8, 2011 Share Posted April 8, 2011 do you want this to be able to send each member the same amount of different amounts? a form with a dropdown box with members listed with a text input next to it should get you started, however that means you would only be able to send to one member at a time. a multiselect box would bring issues of only being able to send the same amount to all members. a form a bit like this would work for one member at a time: <?php if($_POST) { $amount = $_POST['amount']; $sendtomember = $_POST['memberlist']; //i going to skip some obvious stuff like DB connecting,error trapping etc $balance = $row['field']; // execute query to get amount in DB if($amount <= $balance) { //do querys to send amount to member, and subtract from balance of sender, using $amount and $sendtomember variables } else { echo " you cannot send more than you have"; } } ?> <form method="POST"> <select name="memberlist"> <option>Choose a member</option> <option value="1">johnny</option> <!-- value is ID of user in db --> <option value="2">peter</option> </select> <input type="text" name="amount"> <input type="submit" value="send amount"> </form> obviously this code wont work, but like you said, it might point you in the right direction you could be clever and use ajax to add extra rows in the form, if user desired to send to another member, but of course that will involve having more error trapping and multiple querys to DB etc Quote Link to comment https://forums.phpfreaks.com/topic/233136-need-help-creating-form-with-multiple-recievers/#findComment-1199042 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.