Good day!
I have created a form to insert and retrieve data. I need to add a section to insert an image through this form into the database and display it back. But, I don't know the right way to do it because I've tried various ways and still no results :(
I managed to insert the image into the database. But, I failed to retrieve it and view it on my view.php. Here is the code I have made.
view.php
<div class="modal-dialog">
<div class="modal-content">
<form method="POST" action="view.php">
<div class="modal-header">
<form action="papar.php" method="post">
</div>
<div class="modal-body">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="form-group">
<label><strong>ID</strong></label><br>
<?php echo $id ?>
</div>
<div class="form-group">
<label><strong>NAME</strong></label><br>
<?php echo $name ?>
</div>
<div class="form-group">
<label><strong>LOCATION</strong></label><br>
<?php echo $location ?>
</div>
<div class="form-group">
<label><strong>CONTACT NUMBER</strong></label><br>
<?php echo $contact_details ?>
</div>
<div class="form-group">
<label><strong>BRANCH</strong></label><br>
<?php echo $branch ?>
</div>
<div class="form-group">
<label><strong>STATUS</strong></label><br>
<?php echo $status ?>
</div>
<div class="form-group">
<label><strong>CATEGORY</strong></label><br>
<?php echo $category ?>
</div>
<div class="form-group">
<label><strong>MAP (PETA)</strong></label><br>
<?php
$query = "SELECT * FROM `customers.contact` ORDER BY id ";
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result))
{
echo '
<img src="data:image/jpeg;base64,'.base64_encode($row['map'] ).'" height="200" width="200"
';
}
?>
</div>
<div class="form-group">
<label><strong>DETAILS</strong></label><br>
<?php echo $details?>
</div>
<div class="form-group">
<label><strong>FOLLOW UP DATE</strong></label><br>
<?php echo $followup_date?>
</div>
</div>
</div>
<div style="clear:both;"></div>
<div class="modal-footer">
<input type="button" value="Back" onclick="history.back(-1)" />
</div>
</form>
</div>
</div>
</div>