cluce Posted June 11, 2007 Share Posted June 11, 2007 I am creating an account management page that shows the user's contact information and I would like to populate the textfields so that the user doesn't have to type in all his information when he wants to change something. I want to have him type in only the information he wants to change or update. I already have the data displayed on the page. But now I would like to take the data and fill in the textfields with it. If somone show me a small example would appreciate it? Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 11, 2007 Share Posted June 11, 2007 Just query his information from the database and set the default values for the fields to his existing info <?php $query = $db-query("SELECT * FROM users WHERE uid = '$userid'"); $userinfo = $db->fetch_array($query); echo' <form method="post" action="'.$_SERVER['PHP_SELF'].'"> <table> <tr><td><input type="text" name="username" value="'.$userinfo[username].'"> <tr><td><input type="submit" name="submit" value="Update"> </table> </form>'; ?> Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 12, 2007 Share Posted June 12, 2007 Hi, check this code <? $id=1; $sql_sel="select username,email from tablename where id='$id'"; $res=mysql_query($sql_sel); $row=mysql_fetch_array($res); ?> <form method="post" action="'.$_SERVER['PHP_SELF'].'"> <table> <tr><td><input type="text" name="username" value="'.$row[username].'"> <tr><td><input type="text" name="email" value="<?=$row['email']?>"> <tr><td><input type="submit" name="submit" value="Update"> </table> </form> Quote Link to comment Share on other sites More sharing options...
cluce Posted June 12, 2007 Author Share Posted June 12, 2007 here is what I have and I cant get it to display data in the fields. i know my querey works because I Am able to diplay data on page just not in the fields. //create query and retrieve record of user logged on //create and issue the query $SQL = "SELECT * FROM auth_users"; // WHERE username = '".$_SESSION['identity']."'"; $result = mysqli_query($mysqli,$SQL); $row = mysqli_fetch_array($result); ///part of form code/// <td bordercolor="#000000"><input name="firstname" type="text" id="firstname" size="30" maxlength="30" value="<?=.$row['f_name']?>">/> Quote Link to comment Share on other sites More sharing options...
Ultimate Coder Posted November 13, 2009 Share Posted November 13, 2009 hi, try this............. <?php #building connection from specified script #use db connection parameters include("dbconnect.php"); #selecting all users for the table $result = mysql_query("Select * from tblUsers WHERE UserID='SMUNTHALI' ORDER BY UserID ASC"); $row=mysql_fetch_array($result); $f1=$row{'UserID'}; //getting user id $f2=$row{'UserName'}; //getting username ?> <html> <head><title>display data to a form</title></head> <body> <form method="post" action="display_form_data.php"> <table> <tr><td> <input type="text" name="UserID" value="<?php echo $f1 ?>"/> </td></tr> <tr><td> <input type="text" name="UserName" value="<?php echo $f2 ?>"> </td></tr> <tr><td><input type="submit" name="submit" value="Update"></td></tr> </table> </form> </body> </html> <?php mysql_close(); ?> Regards Ulltimate Coder Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.