Home > front end >  I cannot show image in PHP
I cannot show image in PHP

Time:12-30

I'm new to PHP and coding in general, I already made the same lines of code in HTML and it worked fine but when i move it to PHP it wont load.

<div >
   <div >
       <img src="/asset/healy-logo.png" alt="">
   </div>
   <div >
       <img src="/asset/doctor authen.png" alt="">
   </div>
</div>

This is what is shown when i run the html code and my expectation for my php file expectation

But when i run the PHP code it shows an error error

CodePudding user response:

Try this

<div >
<div >
<img src="asset/healy-logo.png" alt="">
</div>
<div >
<img src="asset/doctor authen.png" alt="">
</div>
</div>

If you use "/" in starting of a file path, It will take the first directory as the root directory of your system. this takes the relative path of your project directory

CodePudding user response:

i think you just forget to run with Xampp or something like that (dont forget to click run Apache Server), or you just forgot to copy image folder/file on Xampp Folder. or you just forget to add . if that all still not working you can do inside the HTMl and not HTML inside the

example for inside the HTML :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tes!</title>
    <style>
        body {
            background-color: palevioletred;
            color: white;
        }

        table {
            text-align: center ;
        }
    </style>
</head>
<body>
        <table border="1" cellspacing="10" cellpadding="10">

        <?php
        for ( $i = 10;
              $i <= 100;  
              $i  
        ){

            if ($i % 1) {
                echo '<tr style="background-color: white;">';
            } 

            for ($j = 1;
                 $j <= 100;
                 $j  
            ) {
                echo "<center><td>Arsy I Love You</td></center>";
            }
            echo "</tr>";

        }
        ?>
        
        </table>
</body>
</html>

that's from me, hope thats help you bro!

  • Related