variable question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin Case

    variable question

    Hi, could you perhaps help me out with this, trying to manipulate data from
    a form with multiple radio button groups.

    I have a loop..

    for ($i = 1; $i <= $num; $i++) {

    ...then trying to use $i like this but it doesn't work..

    import_request_ variables('p', 'p_');
    $who = $p_radio$i;

    ...also tried this but no luck..

    $who = $_POST['radio$i'];

    Anyone? Here's a snippet of the form:

    <div class="fileatta chment" id="fileatt1">
    <input type="file" name="fileattac hment1">
    <input type="radio" name="radio1" value="Bob" checked>Bob
    <input type="radio" name="radio1" value="Joe">Joe
    </div>
    <div class="fileatta chment" id="fileatt2">
    <input type="file" name="fileattac hment2">
    <input type="radio" name="radio2" value="Bob" checked="checke d">Bob
    <input type="radio" name="radio2" value="Joe">Joe
    </div>

    Cheers.


  • Janwillem Borleffs

    #2
    Re: variable question

    Justin Case wrote:[color=blue]
    > $who = $_POST['radio$i'];
    >[/color]

    $who = $_POST["radio$i"];

    Mind the double instead of single quotes.


    JW


    Comment

    • Justin Case

      #3
      Re: variable question

      > Mind the double instead of single quotes.

      Thanks alot, that did the trick.


      Comment

      • Iván Sánchez Ortega

        #4
        Re: variable question

        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        Justin Case wrote:
        [color=blue]
        > import_request_ variables('p', 'p_');
        > $who = $p_radio$i;[/color]

        WTF??

        $who = $_REQUEST['p_radio'] + $i;
        $who = $_REQUEST['p_radio'] . $i;
        $who = "{$_REQUEST['p_radio']}$i";

        - --
        - ----------------------------------
        Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net


        Proudly running Debian Linux with 2.6.12-1-686 kernel, KDE3.5.0, and PHP
        5.1.2-1 generating this signature.
        Uptime: 09:46:41 up 12:46, 1 user, load average: 0.94, 1.14, 1.13

        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.2 (GNU/Linux)

        iD8DBQFEBA4t3jc Q2mg3Pc8RAqcFAJ 0bIhUQohRK+LZWC jqPF1cW504hugCf fwSH
        Ww4dkEgtXFa70tW tJv3xYJ0=
        =YzVI
        -----END PGP SIGNATURE-----

        Comment

        Working...