Jump to content

phprookie72

Members
  • Posts

    16
  • Joined

  • Last visited

Posts posted by phprookie72

  1. i am trying to write a form in drupal, here is my plan. I have a database of players name and number, I would like to write a form that allows user to change players number, my question is how would i create a form that display values from the database? The initial form would be players name (title) on left side (name are taken from database) and players number (textfield) on right side with default value from database.

    I guess my question is how do you display dynamic values in drupal form, instead of hard codeing?

  2. this is my form

    if(mysql_num_rows($result)>0)

        {

          $output= "<form action='' method= 'post'><table>";

          while($row= mysql_fetch_array($result))

            {

              $output .= "<tr><td>$row[name]</td>";

              $output .= "<td><input type=text name=playername" . "[$row[name]]" . " value= $row[number]></td></tr>";

     

            }

        $output .= '<tr><td colspan=2><input type=submit name=editplayers value=Submit </td></tr>';

        $output .= '</table>';

        $output .= '</form>';

        }

      else

        $output .= 'no record found';

      echo $output;

     

    }

     

    if(isset($_POST['editplayers']))

      {$arrayname= $_POST['playername'];

        var_dump($arrayname);

      }

  3. here's what i am trying to accomplish, I would get array of name from my db and run a loop to create my form for ie.

        while($row=mysql_fetch_array($result))

            {

              echo '<input type=text name=' . playername[$row['name']] . ' value=' . $row['playernumber']></input>';

            }

     

    is this possible?

    when i use playername[] it works but i get 0,1,2 for index but i would like to use keys as my index.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.