SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Smart programmer silver trophy M.Zeb Khan's Avatar
    Join Date
    Jan 2004
    Location
    Luton, Beds
    Posts
    1,792
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Bulk update textfield values.

    Hi,

    I have a huge form of more than 130 fields (textfields, textareas, checkboxes etc), I have this form in HTML format, I mean its a simple .html page. What I want is, for each field I want to set its value to value="<?=$row['textfieldname'];?>"

    Let's take the following textfield as an example:
    Code:
    <input type="text" name="gender" id="gender" />
    I want to change it to"
    Code:
    <input type="text name="gender" id="gender" value="<?=$row['gender'];?>" />
    I would really appreciate if you can advice an easy way to achieve this.

    PS: I've heard it can be done using Dreamweaver's regular expressions, anybody have this idea?

    Many Thanks in advancee

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you mean is something like -

    Code:
     
    <?php
     
    $query = 'select gender from myTable';
     
    //now run the query
    $rs = mysql_query($query, $conn);
     
    //now output the input elements
    $count = 1;
    while($row=mysql_fetch_assoc($rs)) {
           echo '<input type="text" name="gen_'.$count.'" id="gen_'.$count.'" value="'.$row['gender'].'" />';
    $count = $count + 1;
    }
     
    ?>

  3. #3
    Smart programmer silver trophy M.Zeb Khan's Avatar
    Join Date
    Jan 2004
    Location
    Luton, Beds
    Posts
    1,792
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Kalon,

    Thanks for the nice idea. The problem is, all the fields are grouped and its not possible to run a loop through the fields, what I need is a regular expression kinda solution that will run through the HTML and make the necessary changes to each field. Thanks


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
  •