I would like to retrieve images from phpmyadmin database. Currently, the link of the picture is saved in the database. But when I retrieve it, nothing was shown.
//form2.php (uploading of image)
<div>
<label>Attachment:</label><input type='file' name='img'><br>
</div>
//insert2.php
<?php
$con= mysqli_connect('127.0.0.1','root','');
if(!$con)
{
echo 'Not Connected To Server';
}
if(!mysqli_select_db($con,'satsform1'))
{
echo 'Database Not Selected';
}
$name = $_GET['name'];
$staffno = $_GET['staffno'];
$date = $_GET['date'];
$time = $_GET['time'];
$email = $_GET['email'];
$mobno = $_GET['mobno'];
$roles = $_GET['roles'];
$location = $_GET['location'];
$flightno = $_GET['flightno'];
$flightdate = $_GET['flightdate'];
$seatno = $_GET['seatno'];
$class = $_GET['class'];
$description = $_GET['description'];
$image = $_GET['img'];
$remarks = $_GET['remarks'];
$sql = "INSERT INTO handover (name,staffno,date,time,email,mobno,roles,location,flightno,flightdate,seatno,class,description,image,remarks,status)
VALUES ('$name','$staffno','$date','$time','$email','$mobno','$roles','$location','$flightno','$flightdate','$seatno','$class','$description','$image','$remarks','Pending')";
if(!mysqli_query($con,$sql))
{
echo 'Not Submitted';
}
else
{
echo 'Submitted';
}
header("refresh:2; url=selection.php")
?>
<?php
//fetch3.php
$connect = mysqli_connect('127.0.0.1','root','', 'satsform1');
$output = '';
if(isset($_POST["query"]))
{
$search = mysqli_real_escape_string($connect, $_POST["query"]);
$query = "
SELECT * FROM handover
WHERE name LIKE '%".$search."%'
OR staffno LIKE '%".$search."%'
OR date LIKE '%".$search."%'
OR email LIKE '%".$search."%'
OR mobno LIKE '%".$search."%'
OR roles LIKE '%".$search."%'
OR location LIKE '%".$search."%'
OR flightno LIKE '%".$search."%'
OR flightdate LIKE '%".$search."%'
OR seatno LIKE '%".$search."%'
OR class LIKE '%".$search."%'
";
}
else
{
$query = "
SELECT * FROM handover ORDER BY ID
";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<div class="table-responsive">
<table class="table table bordered">
<tr>
<th>ID</th>
<th>Staff Name</th>
<th>Staff Number</th>
<th>Date</th>
<th>Time</th>
<th>Email</th>
<th>Mobile Number</th>
<th>Roles</th>
<th>Location</th>
<th>Flight Number</th>
<th>Flight Date</th>
<th>Seat Number</th>
<th>Class of Travel</th>
<th>Image</th>
<th> Status </th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["ID"].'</td>
<td>'.$row["name"].'</td>
<td>'.$row["staffno"].'</td>
<td>'.$row["date"].'</td>
<td>'.$row["time"].'</td>
<td>'.$row["email"].'</td>
<td>'.$row["mobno"].'</td>
<td>'.$row["roles"].'</td>
<td>'.$row["location"].'</td>
<td>'.$row["flightno"].'</td>
<td>'.$row["flightdate"].'</td>
<td>'.$row["seatno"].'</td>
<td>'.$row["class"].'</td>
<td><img src="'.$row["img"].'"></td>
<td>'.$row["status"].'</td>
<td> <form action="edit3.php" method="GET">
<input type="hidden" name="update_id" value="'.$row["ID"].'">
<button type="submit">update </button>
</form>
</td>
</tr>
';
}
echo $output;
}
else
{
echo 'Data Not Found';
}
?>
I expect the picture of a particular row will be shown and display the image. So, when I doing the live search engine, the picture will appear under the image column according to their row.
Please change this:
<td><img src="'.$row["img"].'"</td>
To this:
<td><img src="'.$row["img"].'"></td>
Hope this help.