Query show image

Asked

Viewed 786 times

-1

I wonder if I can show an image depending on the name.

 $qr = mysql_query($sql) or die(mysql_error());
 while($exibe = mysql_fetch_array($qr)){
 echo'<div id="tabs-1">
       <p>Nome: '.$exibe["Nome"].'</p>
       <p>Morada:   '.$exibe["Morada"].'</p>
       <p>Distrito: '.$exibe["Distrito"].'</p>
       <p>Concelho: '.$exibe["Concelho"].'</p>

For example: Show me the name of a team (Real Madrid) and I can get it to show me the symbol of it without touching the database.

I can do that?

  • the image is also stored in the database?

1 answer

4


For example, let’s assume it’s stored in Nome the team/team:

echo'<img src="/imagens/'.$exibe["Nome"].'.jpg">

Then you save the image as /imagens/Real Madrid.jpg.

The spelling has to be identical to what is in DB, including the upper and lower case.
In a real use case, the ideal is to normalize the names and remove the spaces and accents by PHP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.