1// database connection
2 $conn = mysqli_connect("localhost", "root", "", "student");
3// Fetch image from database
4 $img = mysqli_query($conn, "SELECT * FROM student_table");
5 while ($row = mysqli_fetch_array($img)) {
6
7 echo "<img src='images/".$row['imagename']."' >";
8
9 }
1// Get the name of images
2 $Get_image_name = $_FILES['image']['name'];
3
4 // image Path
5 $image_Path = "images/".basename($Get_image_name);
6
7 $sql = "INSERT INTO student_table (imagename, contact) VALUES ('$Get_image_name', 'USA')";
8
9 // Run SQL query
10 mysqli_query($conn, $sql);
11
12 if (move_uploaded_file($_FILES['image']['tmp_name'], $image_Path)) {
13 echo "Your Image uploaded successfully";
14 }else{
15 echo "Not Insert Image";
16 }
17 }
1<?php // Include the database configuration file require_once 'dbConfig.php'; // Get image data from database $result = $db->query("SELECT image FROM images ORDER BY uploaded DESC"); ?>
2
3<?php if($result->num_rows > 0){ ?> <div class="gallery"> <?php while($row = $result->fetch_assoc()){ ?> <img src="data:image/jpg;charset=utf8;base64,<?php echo base64_encode($row['image']); ?>" /> <?php } ?> </div> <?php }else{ ?> <p class="status error">Image(s) not found...</p> <?php } ?>