Pregunta

Hello I have in my DB a column called capalivro that has my image paths. I want to make the img src the content of that column, but I'm not succeding in doing this since I don't know how to put that PHP var in the HTML. This way I tried doesn't work because the php doesn't work because of the quotation marks.

<?php while ($livro = mysql_fetch_assoc($livrotodos)) { ?>
        <div class="large-2 columns">
          <div class="livro">
            <div class="livro-overlay">
              <h3><?php echo $livro['nomelivro'] ?></h3>
            </div>
            <img src= "<?php $livro['capalivro']?>" />
          </div>
        </div>
        <?php } 
        ?>
¿Fue útil?

Solución 2

change your line containing the img src= bit to:

<img src="<?php echo $livro['capalivro']?>" />

without the echo part, it won't display the "string" from the database.

Otros consejos

</div>
        <img src= "<?php $livro['capalivro']?>" />
      </div>

should be:

</div>
        <img src= <?php echo "\"". $livro['capalivro']."\""?> />
      </div>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top