How to organize BDados results

0

Hello, I'm doing a movie site and would like some help on that part.

After getting connection to DB, I want every record to appear within the grid I made.

I'll explain it better with photos.

EachmoviehasitsrecordcontainingeveryinformationIwanttomanipulate.

Above shows how I call my script PHP that contains the connection to DB.     however it shows the 2 record in the same place,     I wanted movie 1 to be at location 1 and so on. follows the grid layout !

ThisisthePHPfile

<?php$conecta=mysql_connect("127.0.0.1", "root", "") or print (mysql_error()); 
mysql_select_db("bd", $conecta) or print(mysql_error()); 


 $filmes = mysql_query("SELECT * FROM filmes");
    while($dados = mysql_fetch_array($filmes)){

         echo $dados['nome'] . "<br>";
         echo $dados['sinopse'] . "<br>";
         echo $dados['categoria'] . "<br>";

    }


?>
    
asked by anonymous 25.02.2015 / 13:37

1 answer

3

As you are doing, you will have to concatenate the HTML within the php file.

<?php 
$conecta = mysql_connect("127.0.0.1", "root", "") or print (mysql_error()); 
mysql_select_db("bd", $conecta) or print(mysql_error()); 

$filmes = mysql_query("SELECT * FROM filmes");
$size = 0;
while($dados = mysql_fetch_array($filmes)){
     if($size == 0)
         echo "<ul>";
     echo "<li>";
     echo $dados['nome'] . "<br>";
     echo $dados['sinopse'] . "<br>";
     echo $dados['categoria'] . "<br>";
     echo "</li>";
     if($size == 2)
         echo "</ul>";
     $size++;
     $size = $size == 3 ? 0 : $size;
}
?>

And in your HTML, change to:

<div><?php include("get.php"); ?></div>
    
25.02.2015 / 13:46