Help with autocompleting form based on whats already in mysql

Discussion in 'PHP' started by Josh-H, Jul 19, 2007.

  1. #1
    Ok so I am doing an editprofile feature for my website but how can I do it so it fills the form with its current data.

    The current data is $row[fname] and part of the form is

    <input type="text" size="25" maxlength="255" class="input" name="fname">

    I know I need to use the value=" " tag but should I echo the whole form tag or just inside the value tag etc..

    Please show me how I should and I will +rep.
     
    Josh-H, Jul 19, 2007 IP
  2. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #2
    One way to do it.
    
    <?php
    
    echo '<input type="text" size="25" maxlength="255" class="input" value="'.$row['fname'].'" name="fname">';
    
    ?>
    
    PHP:
    A different way to do it.
    
    <?php
    
    $var = $row['fname'];
    
    ?>
    
    <input type="text" size="25" maxlength="255" class="input" value="<?php echo $var; ?>" name="fname">
    
    PHP:
     
    exodus, Jul 19, 2007 IP