I have a bunch of data with information from various bands, however I would like to pull them to my front page.
Bank name: dados
Table called: Artists
where I have the information in it:
-
imagem_small
(in this case I use url stored from the images of the bands) -
Name
- band name -
spotify_popularity
- band popularity
The idea would be to show the above image and artist name below in a column with 7 artists and that only bands with popularity under 20 would appear in the random column.
would be like this site link
This code is what I'm using to pull the content. localhost I'm using, so I do not have password database.
I wonder if something is wrong or I have to put something else in it ... since the code does not work.
ps. I copied exactly as it is.
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dados";
//conexão ao banco de dados
$conn = new mysqli($servername, $username, $password, $dbname);
//consulta a tabela Artistas onde spotify_popularity é menor que 20 no total de 7 registros
$consulta = "SELECT * FROM artists WHERE spotify_popularity < 20 limit 7";
$result = $conn->query($consulta);
$i=1;
echo '<div id="container">';
while($dados = $result->fetch_array()){
echo "<div id='box-".$i."' class='box'>";
echo "<img src=". $dados["imagem_small"]. ">";
echo "<br>";
echo "<span>". $dados["Name"]. "</span>";
echo "</div>";
$i++;
}
echo '</div>';