technickul Posted April 1, 2010 Share Posted April 1, 2010 Can someone point me in the direction as to how can I pull information from a database and set the values in the form using that information? I know I will have to use a query and thats not the part I need help with its setting the text box values I don't know how to go about doing it. What I'm trying to do ultimately is create an edit account page where the user information is pulled in and they can modify it as they see fit. I've searched google quite a bit but when ever I search I always get the opposite of what I need. thanks! Quote Link to comment Share on other sites More sharing options...
darkagn Posted April 1, 2010 Share Posted April 1, 2010 Let's assume you have created a select query and retrieved the results into an associative array called $row. Here is how you set the values to the text boxes: $id = $row["USER_ID"]; if($id < 0) $username = 'New User'; else $username = $row["USERNAME"]; echo "<input type='text' value=$id name='id' />"; echo "<input type='text' value=$username name='username' />"; and so on. Basically the value setting will allow you to initialise your text boxes (or any other input for that matter) to a value, and the name field is used to retrieve it after the form is posted like so: if(isset($_POST["submit"])) { $id = $_POST['id']; $username = $_POST['username']; // send the details to the database. } Quote Link to comment Share on other sites More sharing options...
technickul Posted April 1, 2010 Author Share Posted April 1, 2010 Thanks thats much appreciated! 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.