Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    melbourne australia

    Unanswered: query > insert multiple records question

    what values are passed through to the processing of aform. inparticularly, the amtpaid$userid bit, is it just the number or does this mean amtpaiduser1 = 2080 (if that is the entered number).

    PHP Code:

        <td width=10>&nbsp;</td>
        <td><?= $userid ?></td>
        <td><?= $rentamt ?></td> 
        <td><input size="10" maxlength="10" type="text" value="0" name="amtpaid<?= $userID ?>"></td>
        <td><input size="10" maxlength="10" type="text" value="4" name="currentperiod<?= $userID ?>"></td> 

    the thing is, from the above example, there are 4 sets of data I want to add to the recordset.

    plus I need to calculate a $balance figure before i insert the data

    the $balance figure = houserentamt - amtpaid (so if someone hasn't paid anything there $balance = -(their own)rentamt.

    do i calculate this now, or in the form processing part.


    my $query2 in the form processing part is:

    PHP Code:

    "INSERT INTO rent_transaction ( id, userid, currentperiod, amtpaid, balance) VALUES ('null',  '$userid', '$currentperiod', '$amtpaid', '$balance')"

    so this is where i am stuck, as i am not sure how much data is being passed through from the form, or how to work out the $balance figure.

    so for instance, as my end result i need something like this being generated:

    PHP Code:

    INSERT INTO rent_transaction 

    any ideas?

  2. #2
    Join Date
    Dec 2002
    have you figured it out yet - its been some time since you posted - and I just now joined the forum.

    It looks like you are just now trying to learn to implement PHP - am I right?

  3. #3
    Join Date
    Dec 2002

    Hope this helps...

    Well not sure if you worked through your problems or not, but it sounds like you are asking how to process form data. If your forms are submitted via the post method then you can access all your variables on your form processing page (after the form has been submitted) via $_POST['varname'], so in your case on your form processing page you'd have:

    $balance figure = $houserentamt - $_POST['amtpaid'];
    (not sure where $houserentamt comes from I'm assuming it wasn't from the form)

    If you're not using the post method with your forms (when the variable names and values get appended to the URL when you submit them) use $_GET['varname'] like:

    $balance figure = $houserentamt - $_GET['amtpaid'];

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts