How can i retrieve or fetch the image which is saved in my directory?
This is my dashboard where i use a link to fetch the data’s.
<body>
<?php include('session.php') ?>
<h2 style="text-align:center; color:orangered;">
DASHBOARD
</h2>
<table>
<h3>
<tr style="background-color:#E4EBC5; color:orangered;">
<th>Nearmiss No.</th>
<th>Details</th>
<th>location</th>
<th>Date</th>
<th>Time</th>
<th>Status</th>
</tr>
</h3>
</table>
<?Php
////////////////////////////////////////////
require "dbconfig.php"; // MySQL connection string
$count="SELECT id,details,location,date,time,checkbox,comment,reportedname,status FROM proposals WHERE YEAR(date) = YEAR(CURDATE())";
if($stmt = $connection->query($count)){
while ($nt = $stmt->fetch_assoc()) {
echo "
<body>
<table>
<tr>
<td><a href=view.php?id=$nt[id]>$nt[id] Reporter name:$nt[reportedname]</a></td>
<td>$nt[details]</td>
<td>$nt[location]</td>
<td>$nt[date]</td>
<td>$nt[time]</td>
<td>$nt[status]</td>
</tr>
</table>
</body>
";
}
}else{
echo $connection->error;
}
?>
<style>
table {
font-family: arial, sans-serif;
border-collapse: separate;
width: 100%;
table-layout: fixed;
background-color: #EBFFE3;
overflow: auto;
flex:1;
text-overflow: ellipsis;
}
td, th {
border: 1px solid #90D199;
text-align: left;
padding: 8px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
tr:nth-child(even) {
background-color: #dddddd;
text-overflow: ellipsis;
}
</style>
</body>
This is my view.php where i can fetch and view the data using ID’s. Kindly help how to fetch the images which are saved in my directory and the name of the same from database?
<?Php
////////////////////////////////////////////
// Collecting data from query string
$id=$_GET['id'];
// Checking data it is a number or not
if(!is_numeric($id)){
echo "Data Error";
exit;
}
// MySQL connection string
require "dbconfig.php";
$count="SELECT * FROM proposals where id=?";
if($stmt = $connection->prepare($count)){
$stmt->bind_param('i',$id);
$stmt->execute();
$result = $stmt->get_result();
$row=$result->fetch_object();
}else{
echo $connection->error;
}
?>
<html lang = "en">
<head>
<title>Proposals</title>
<meta charset = "UTF-8" />
</head>
<body><button onclick="myFunction()">Print</button>
<script>
function myFunction() {
window.print();
}
</script>
<h1>Proposal form</h1>
<form>
<fieldset>
<legend>Proposal no</legend>
<p>
<b style="font-size:17px; color:black; position: absolute; top:130px;">Details of incident :</b>
<textarea style="position:relative;" disabled id = "myTextArea"
rows = "5"
cols = "110"><?php echo $row->details?></textarea>
</p><br>
<fieldset style="height:55px; width:848px; border:1px solid #888;">
<p>
<b style="font-size:17px; color:black; position: relative; bottom:-5px;">Location :</b>
<textarea style="position:absolute; left:115px;" disabled id = "myTextArea"
rows="2" cols="56"><?php echo $row->location?></textarea>
</p>
<br>
<p>
<b style="font-size:17px; color:black; position:relative; left:545px; bottom:80px;" >Date :</b><textarea style="position:relative; left:555px; bottom:70px;" disabled id = "myTextArea"
rows="2" cols="10"><?php echo $row->date?></textarea>
</p>
<p>
<b style="font-size:17px; color:black; position:relative; left:708px; bottom:135px;" >Time :</b><textarea style="position:relative; left:715px; bottom:125px;" disabled id = "myTextArea"
rows="2" cols="10"><?php echo $row->time?></textarea>
</p>
</fieldset>
<p><b>Classification(Tick the appropriate one, Leave blank if you find it difficulty)</b><br>
<label style="font-size:16px;color:black;">Selected Classification :</label>
<textarea style="position:relative; bottom:-3px;" disabled id = "myTextArea"
rows="1" cols="47"><?php echo $row->checkbox?></textarea>
</p>
<p>
<b style="font-size:17px;color:black;">Details of Injured :</b><br>
<b>Name:</b>
<textarea style="position:relative; bottom:-5px;" disabled name="name" cols="25" rows="1" class="form-control"> <?php echo $row->injured?></textarea>
</p>
<p style="position:relative; left:280px; bottom:35px;">
<b style="position:relative; bottom:4px;">Age/Gender :</b>
<textarea disabled name="agegender" cols="3" rows="1"><?php echo $row->agegender?></textarea>
</p>
<p style="position:relative; left:435px; bottom:75px;">
<b style="position:relative; bottom:4px;">Contact :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $row->contact?></textarea>
</p>
<p style="position:relative; left:600px; bottom:115px;">
<b style="position:relative; bottom:4px;">Organization :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $row->organization?></textarea>
</p>
<p style="position:relative; left:0px; bottom:125px;">
<b style="position:relative; bottom:4px;">Department :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $row->dept?></textarea>
</p>
<p style="position:relative; left:226px; bottom:165px;">
<b style="position:relative; bottom:4px;">Employee ID :</b>
<textarea disabled name="agegender" cols="9" rows="1"><?php echo $row->empid?></textarea>
</p><br>
<p>
<b style="font-size:17px; color:black; position: relative; bottom:204px;">summary of Incident :</b>
<textarea style="position:absolute; left:25px; top:525px;" disabled id = "myTextArea"
rows="8" cols="110"><?php echo $row->summary?></textarea>
</p>
<div class="form-group">
<label style="position:absolute; left:75%; top:505px;"><b>Uploaded Images Here :<?php echo "<img src='".$row['image']."' />";?> </b></label>
</div>
</fieldset>
</form>
</body>
</html>