What's new

Diko tlga mapalabas yun picture

loktoy

Eternal Poster
Joined
Oct 20, 2014
Posts
1,168
Solutions
2
Reaction
103
Points
497
Age
30
tama po ba code ko sa pag palabas ng picture. nasa database ko na kasi sya ngaun palalabasin ko na sya

<?php
session_start();
include "../config/config.php";
if(isset($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
$_GET_RECORD = mysqli_query($con,"SELECT * FROM registration WHERE user_id = '$user_id' ");
while($row_edit = mysqli_fetch_assoc($_GET_RECORD)) {

$file_path = $row_edit['img']; // ito ay nasa database na to

echo "<img src='$row_edit ['img']'; alt='Uploaded Image' width='200'>"; // Add this line
echo "<img src='$file_path' alt='Uploaded Image' width='200'>"; // Add this line

}
?>
 
Based on the code you provided, there are a few issues that need to be addressed in order for the picture to be displayed correctly.

1. Check the table name in the SQL query: The table name should be enclosed within backticks () instead of square brackets []. So, instead of registration, it should be registration`.

2. Remove unnecessary semicolon in the echo statement: The semicolon after $row_edit ['img'] should be removed.

Here's the modified code:

PHP:
<?php
session_start();
include "../config/config.php";
if(isset($_SESSION['user_id'])){
    $user_id = $_SESSION['user_id'];
    $_GET_RECORD = mysqli_query($con,"SELECT * FROM `registration` WHERE user_id = '$user_id' ");
    while($row_edit = mysqli_fetch_assoc($_GET_RECORD)) {
        $file_path = $row_edit['img']; // ito ay nasa database na to 
        echo "<img src='$file_path' alt='Uploaded Image' width='200'>"; // Display the image
    } 
}
?>

Make sure that the $file_path variable contains the correct path to the image file in the database. Also, ensure that the image file exists in the specified path.
 
ano bang nkalagay sa database? directory ba ng image file? if Oo, double check mo if valid ba ang directory ng file.
 

Similar threads

Back
Top