Jump to content

Recommended Posts

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

 

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.