How to display a specific image?

4

I'm making a movie system that registers the poster of the movie and I want it when I generate the report with all the films registered, it shows me the image of the poster saved in the bank and not the name of the image. I found a code that shows all the images in a table of the bank, however it shows all one underneath the other and in the report I want it to show separated, by the side of the name, for example:

Title .................. Director ................... Poster

13: The player ..... Gela Babluani ....... Image

The code I found on the internet and I'm basing it on is the following:

<?php

include ('config.php');

$sql = mysql_query("SELECT * FROM filmes ORDER BY nome_filme");

while ($filmes = mysql_fetch_object($sql)) {

echo "<img src='fotos/".$filmes->foto."' alt='Foto de exibição' /><br />";

?>

Name of the table in the bank: movies Variable name of poster image: $ photo Movie name variable name: $ movie_name

    
asked by anonymous 16.09.2015 / 22:31

1 answer

3

I would do it this way:

<?php
include ('config.php');
$sql = mysql_query("SELECT * FROM filmes ORDER BY nome_filme");

    echo "
    <table>
        <tr>
            <td>COD</td>
            <td>Título</td>
            <td>Diretor</td>
            <td>Imagem</td>
        </tr>
    ";
    while ($filmes = mysql_fetch_array($sql)) {
        echo "
        <tr>
            <td>".$filmes['id']."</td>
            <td>".$filmes['titulo']."</td>
            <td>".$filmes['diretor']."</td>
            <td><img src='fotos/".$filmes['foto']."'></td>
        </tr>
        ";
    }
    echo "</table>";
?>
    
16.09.2015 / 22:36