Thread: loop problems

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Cape Town, WP, South Africa
    Posts
    39
    Rep Power
    14
    I am having a similar problem with the for loop, but I think my logic may be flawed.

    I a previous form I have created a table in a while loop from a data base, next to the data retrieved I have included text boxes.

    here is a slice of the code (while (@row=$sth->fetchrow) {
    $custid = $row[0];
    print " <tr>
    <td><font size = '5'>$row[1]</font></td>
    <td><input type = 'text' size = '4'
    name = '$custid&&amount'></td>
    <td><select name = '$custid&&size'>
    <option> 20
    <option> 40
    </select></td>
    <td><select name = '$custid&&type'>
    <option> gp
    <option> si
    <option> fr
    <option> ot
    <option> re
    <option> hr
    <option> tk
    </select>
    </td>
    </tr>";
    }

    on submission of the form I want to write the info to data base so I named the select and text boxes $custid&&(item_name)
    where $custid = a unique customer id in my data base.

    My cgi that is simply trying to catch the data is
    #cerlbinperl.exe;

    use CGI;


    $q = new CGI;
    print $q->header;
    print "<html>
    <head>
    </head>
    <body>";
    $check = $q->param('2&&size');

    for ($s=1; $s<10;$s++)

    { $siz = $q->param('$s&&size');
    print"<br>$siz";

    }


    print "<br>$check</body></html>";


    this does not work $check however picks up one entry.

    any ideas, suggestions will be most welcome
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    82
    Rep Power
    14

    Well, it's not going to interpolate your variable values because of the single quotes:

    $siz = $q->param('$s&&size');

    So try some double quotes.

    Good luck.

    Josh

IMN logo majestic logo threadwatch logo seochat tools logo