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

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.