Professional Web Applications Themes

variables and arrays - PHP Development

Hi guys, Thanks for your help. Can anyone tell me what is wrong with this script. Because I couldt send the values of Name_2 or Name_3 when I submit the form and check the email. This is just a piece of my html and my php code. Name_2 ....... Name_200. Thanks again in advance for example Name : whatever Res Phone : 9458943 Email : whateverwhatever Bus Phone : 9489584 The Total is 230 I would like to get by submission Name : whatever Res Phone : 9458943 Email : whateverwhatever Bus Phone : 9489584 Bookshelves : 130 Chair : ...

  1. #1

    Default variables and arrays

    Hi guys,

    Thanks for your help.

    Can anyone tell me what is wrong with this script. Because I couldt send the
    values of Name_2 or Name_3 when I submit the form and check the email.
    This is just a piece of my html and my php code. Name_2 ....... Name_200.
    Thanks again in advance


    for example

    Name : whatever
    Res Phone : 9458943
    Email : whateverwhatever
    Bus Phone : 9489584
    The Total is 230

    I would like to get by submission

    Name : whatever
    Res Phone : 9458943
    Email : whateverwhatever
    Bus Phone : 9489584
    Bookshelves : 130
    Chair : 60
    Chair Rocker : 40
    The Total is 230

    Here is my html

    <form method="POST" name="EstimationForm" action="estimate.php">
    <input type="text" name="GI_name" size="24" class="txt2">
    <input type="text" name="GI_resphone" size="24" class="txt2">
    <input type="text" name="GI_email" size="24" class="txt2">
    <input type="text" name="GI_busphone" size="24" class="txt2">

    <input type="text" size="2" maxlength="3" name="item_2" class="txt2"><input
    type="hidden" name="Weight_2" value="65">
    <input type="hidden" name="Name_2" value="Bookshelves, per section"></td><td
    class="txt3">

    <input type="text" size="2" maxlength="3" name="item_3" class="txt2"><input
    type="hidden" name="Weight_3" value="60">
    <input type="hidden" name="Name_3" value="Chair, Arm"></td>

    <input type="text" size="2" maxlength="3" name="item_4" class="txt2"><input
    type="hidden" name="Weight_4" value="40">
    <input type="hidden" name="Name_4" value="Chair Rocker (wood)"></td>


    my php script
    <?
    $FTGGI_name = $_POST['GI_name'];
    $FTGGI_resphone = $_POST['GI_resphone'];
    $FTGGI_email = $_POST['GI_email'];
    $FTGGI_busphone = $_POST['GI_busphone'];
    for($i=2;$i<166;$i++){
    $FTGName[$i] = $_POST["item_$i"] * $_POST["Weight_$i"];
    $FTGtotal += $FTGName[$i];
    }
    $to = "com";
    $subject = "Estimation Request";
    $body = "Customer Name : $FTGGI_name\n"
    . "Customer Residence Phone: $FTGGI_resphone\n"
    . "Customer Email: $FTGGI_email\n"
    . "Customer Business Phone: $FTGGI_busphone\n"
    for($i=2;$i<166;$i++){
    .. "$_POST["name_$i"] . " : " . $FTGName[$i] . "\n" ";
    }
    . "Total is $FTGtotal\n";

    ?>




    ozgur Guest

  2. #2

    Default Re: variables and arrays

    On Thu, 14 Jul 2005 23:00:25 -0400, "ozgur teksin"
    <com> wrote:
     

    Using your present code, the way to call the variables would be:
    $_POST['item_'.$i]

    Another option would be to create an array of each post variable with
    the same name:
    <input type="text" name="txt[]">
    <input type="hidden" name="Weight[]">
    <input type="hidden" name="Name[]">

    Then your for statement would be more like:
    for ($i=0; $i<count($_POST['txt']; $i++)
    {
    $body .= $_POST['txt'][$i]...
    }
    Tyrone Guest

  3. #3

    Default Re: variables and arrays

    ozgur teksin wrote:
     
     


    PHP is case-sensitive ie. "name_2" != "Name_2";



    -veikko

    --
    veikko
    mail .com
    makinen
    Veikko Guest

Similar Threads

  1. Using PHP variables flash <specialy Arrays>
    By imFresher in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: January 10th, 07:23 PM
  2. Arrays as session variables
    By maddiel in forum Macromedia ColdFusion
    Replies: 1
    Last Post: February 26th, 11:19 PM
  3. loading external variables via arrays. Please help.
    By exorș webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 4
    Last Post: January 13th, 10:09 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139