Hello every one,
I have made the insertion, viewing part of the database, but want to have an edition part too, could anyone plz kindly guide me, how it is possible to have edition part too?

NOTE;
I am using PHP 5..., MySQl 5... , and Apache Server

Thanks for replying,
Yes, I insert the data through the HTML form into the database, and now I want to have edition part too, but I dont know how to manage that

So, only thing you have to do is to select records from the database and put them in the forms ( value="..." ). After submit you update the database with the new values.

Example :

<?php

// connect to SQL server and select DB
// ..
// your query will select to edit record by id if you have one

$query = "SELECT name, phone, mail from table where id='$id' ";

$result = mysql_query($query, $link);

$row = mysql_fetch_array($result);

?><form action="edit.php" method="POST">
<input type="text" name="name" value="<?php echo $row['name']; ?>">
<input type="text" name="phone" value="<?php echo $row['phone']; ?>">
<input type="text" name="mail" value="<?php echo $row['mail']; ?>">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" name="submit" value="Edit">
</form>

edit.php

<?php

// connect to DB server and select DB
....
// validate form data
// ...

$query = "UPDATE table SET name='$_POST[name]', phone='$_POST[phone]', name='$_POST[mail]' WHERE id='$_POST[id]' ";

// ...

?>

- Mitko Kostov

Thanks very much, I will try to go through your code, and then if still had problem, posting here...

This article has been dead for over six months. Start a new discussion instead.