sql - PHP - Show Image From Database -


first of all, i've known there similiar questions in stackoverflow show images in php. but, code simple, & not complicated others, hope can answer in simple way.

in database, have mahasiswa table. has these fields:

nrp | nama | pass | jatah_sks | foto_profil

i want program show foto_profil image. images saved in folder propic. code:

$sql4 = "select foto_profil mahasiswa"         . " nrp=".$nrp; $result4 = mysqli_query($link, $sql4); if (!$result4) {       die("<h3>sql error</h3>" . $sql4); } $row4 = mysqli_fetch_array($result4);  <img src="propic/<?php echo $row4['foto_profil'] ?>"/> 

the code shows no errors, foto_profil won't showed up. shows break-image icon. how right code? please explain answer. thanks

you mixing php , html here.. want this:

$sql4 = "select foto_profil mahasiswa"         . " nrp=".$nrp; $result4 = mysqli_query($link, $sql4); if (!$result4) {       die("<h3>sql error</h3>" . $sql4); } while ($row4 = mysqli_fetch_array($result4)) {     echo '<img src="propic/' . $row4['foto_profil'] . '"/>'; } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -