Jump to content

Recommended Posts

GUYS i want to display data into forms which includes buttons,text box and list box using php where data is retrived from mysql db

 

i just want to retrieve the datas already stored in db and make it editable..

 

 

please help.........

<?php
$result = mysql_query("SELECT * FROM user WHERE id='123'");
$row = mysql_fetch_assoc($result);
?>
<form>
name: <input type="text" name="name" value="<?php print (strlen($_POST['name']) ? $_POST['name'] : $row['name']); ?>" /><br />
email: <input type="text" name="email" value="<?php print (strlen($_POST['email']) ? $_POST['email'] : $row['email']); ?>" /><br />
</form>

 

Get the idea? If the form is submitted with new data and there are errors (you will have to validate the input) the fields will retain the new data entered, otherwise they will display the default values from the database. However I would not recommend putting POST data back into an input field until it has been sanitized i.e. remove sql injection, html, javascript, etc

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.