0
I have a database of books each book has its ISBN, title etc and even has an image, which I uploaded in the database for each book. but the problem is that the image does not appear, does the image echo but in reality does not appear (see the photos). The code I’m using to call up the database image is as follows:
<?php
include('config.php');
$sql= "SELECT * FROM books WHERE category='computing'";
$r=mysqli_query($conn, $sql);
?>
<html>
<head>
</head>
<body>
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<th>ISBN</th>
<th> Title </th>
<th> Author's name</th>
<th> edition</th>
<th> year</th>
<th> category</th>
<th> publisher</th>
<th> quantity-in-stock</th>
<th> price</th>
</tr>
<?php while($books =mysqli_fetch_object($r)){?>
<tr>
<td> <?php echo $books->ISBN; ?></td>
<td> <?php echo $books->Title; ?></td>
<td> <?php echo $books->Authorsname; ?></td>
<td> <?php echo $books->edition;?></td>
<td> <?php echo $books->year; ?></td>
<td> <?php echo $books->category; ?></td>
<td> <?php echo $books->publisher; ?></td>
<td> <?php echo $books->quantityinstock; ?></td>
<td> <?php echo $books->price; ?></td>
echo '<img src="data:image/jpeg;base64,'.base64_encode( $books->Image ).'"/>';
<td> <a href="shoppingcart.php?ISBN=<?php echo $books->ISBN; ?>">Order Now</a></td>
</tr>
<?php } ?>
</table>
</body>
</html>
The base I am using is phpmyadmin and it speaks "binary" please see the photo. I’m sorry if it’s a basic question, but I’m new at this and I don’t quite understand.
Thank you
hi, I tried but it didn’t work, I’ll put the whole code. so it might be something I’m not doing well
– Diana Madeira
Note that the line that has the echo command is not inside the php tags (if it really is in your code, it must be printing the entire line in your table). I tested with png image (image/png) and had the behavior experienced. I don’t know the reason, but I’ve had trouble displaying images with the extension. JPG (uppercase instead of minuscule). Anyway try with a different mime.
– Juven_v
Voce tested with php tags?
– Diana Madeira
Yes, I put inside the php tags.
– Juven_v
I tried and it worked, thank you
– Diana Madeira