This is my first project. I want, when I update my record at that time in form all fields are pre filled with previous data.Which are stored in table.
This is my Function code:-
public function getData($query)
{
$result = $this->connection->query($query);
if ($result == false) {
return false;
}
$rows = array();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
return $rows;
}
This is my html file code:
<?php
$result = $crud->getData("SELECT * FROM creative_workshop ");
foreach ($result as $res) {
$id = $res['id'];
$title = $res['title'];
$message = $res['message'];
$title1 = $res['title1'];
$message1= $res['message1'];
$image1= $path .$res['image1'];
$title2 = $res['title2'];
$message2= $res['message2'];
$image2= $path .$res['image2'];
}
?>
<form name="form" method="post" action="" enctype="multipart/form-data">
<textarea rows="4" cols="50" name="title" value="<?php echo $title;?>">
<textarea rows="4" cols="50" name="message" value="<?php echo $message;?>">
</form>