SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast mathi's Avatar
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    creating x time same field

    I would like to create a form in which when entered a number, there is a table created (mysql) with x time the same field (in which x is the number entered in the form. Is this possible en how would it have to be done?
    thnx

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mathi
    I would like to create a form in which when entered a number, there is a table created (mysql) with x time the same field (in which x is the number entered in the form. Is this possible en how would it have to be done?
    thnx
    PHP Code:
    <?php
    switch ($_POST['submit_value']) {
       case 
    'Submit':
          
    //Connect to database
          //...

          
    $x = (int)$_POST['x'];
          for (
    $i=1$i<=$x; ++i) {
             
    mysql_query("INSERT INTO table1 (column1) VALUES ('blah')");
          }
          break;

       default:
          
    ?>
          <form name="duplicate" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
              X: <input name="x" type="text" value="0">
              <input name="submit_value" type="submit" value="Submit">
          </form>
          <?php
    }
    ?>
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Enthusiast mathi's Avatar
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great
    Thanx a lot

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mathi
    Great
    Thanx a lot
    Hey no problem
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •