Array in PHP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Array in PHP

nov8998nov8998 Posts: 5Member
i've prob with array.i want the value of each txtbox will store in an array. but the coding i've done doesn't work. hope can guide me. Below is part of my coding.
...
">
<?php
if (isset($_POST['cmdSubmit'])){
for ($intBilU=1 ;$intBilU<=3;$intBilU++)
{
$dbUName[$intBilU] =Trim($_POST['txtUName[$intBilU]']);
$dbUProg[$intBilU] =Trim($_POST['txtUProg[$intBilU]']);
$dbUGradYr[$intBilU] =Trim($_POST['txtGradYr[$intBilU]']);
}}
?>
<?PHP for ($intBilU=1 ;$intBilU<=3;$intBilU++){
echo "<TR>University # $intBilU
" .
"
" .
"
" .
"
" .
"
" .
"
";
}?>
Program/Achievement
Graduation Year


Comments

  • netgertnetgert Posts: 331Member
    : i've prob with array.i want the value of each txtbox will store in an array. but the coding i've done doesn't work. hope can guide me. Below is part of my coding.
    : ...
    : ">
    : <?php
    : if (isset($_POST['cmdSubmit'])){
    : for ($intBilU=1 ;$intBilU<=3;$intBilU++)
    : {
    : $dbUName[$intBilU] =Trim($_POST['txtUName[$intBilU]']);
    : $dbUProg[$intBilU] =Trim($_POST['txtUProg[$intBilU]']);
    : $dbUGradYr[$intBilU] =Trim($_POST['txtGradYr[$intBilU]']);
    : }}
    : ?>
    :
    : <?PHP for ($intBilU=1 ;$intBilU<=3;$intBilU++){
    : echo "<TR>University # $intBilU
    " .
    : "
    " .
    : "
    " .
    : "
    " .
    : "
    " .
    : "
    ";
    : }?>
    Program/Achievement
    Graduation Year
    :
    :

    :
    :
    :

    Not quite sure, but this is what it should be
    [code]
    ">
    <?php
    if (isset($_POST['cmdSubmit'])){
    for ($intBilU=1 ;$intBilU<=3;$intBilU++)
    {
    // php will translate the post vars into php-style arrays automatically
    $dbUName[$intBilU] =Trim($_POST['txtUName'][$intBilU]);
    $dbUProg[$intBilU] =Trim($_POST['txtUProg'][$intBilU]);
    $dbUGradYr[$intBilU] =Trim($_POST['txtGradYr'][$intBilU]);
    }}
    ?>
    <?PHP for ($intBilU=1 ;$intBilU<=3;$intBilU++){
    // sometimes php has troubles identifying where the variable ends when using characters used in php syntax for variables ([] for arrays) so its better to escape from strings
    echo "<TR>University # $intBilU
    " .
    "
    " .
    "
    " .
    "
    " .
    "
    " .
    "
    ";
    }?>
    Program/Achievement
    Graduation Year


    [/code]
    [hr][red][italic][b]N[/b][/red][blue]et[/blue][red][b]G[/b][/red][blue]ert[/italic][/blue][hr]

Sign In or Register to comment.