0
I have a small problem, I have a page that lists several movies that I have in the database, which is placed in a table but only that I create that every 5 movies a br Automatic!
How could I do that?
Code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function exit(){
var link = window.location.href;
var split = link.split("/");
var url = split[2];
window.location = "http://" + url + "/IMMStart/principal/sair";
}
</script>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<?php echo PATH; ?>css/bootstrap.min.css" rel="stylesheet">
<?php
if(isset($_COOKIE['key-login'])){
$keylogin = $_COOKIE['key-login'];
$pesquser = BD::conn()->prepare("SELECT * FROM `auth-keys` WHERE auth_key = ?");
$pesquser->execute(array($keylogin));
if($pesquser->rowCount() == 0){
setcookie("key-login", "",time()-3600, "/");
echo '<script>alert("Cookie Invalido!"); location.href="'.PATH.'"; </script>';
}else{
$respesquser = $pesquser->fetchObject();
$iduser = $respesquser->id_user;
$queryuser = BD::conn()->prepare("SELECT * FROM `users` WHERE id = ?");
$queryuser->execute(array($iduser));
$resuser = $queryuser->fetchObject();
$firstacesspospass = $resuser->firstacessposrecoverpass;
$firstacess = $resuser->firstacess;
if($firstacesspospass == 1){
header("Location: " . PATH . "pospass");
}
if($firstacess == 1){
header("Location: " . PATH . "start");
}
}
}else{
echo '<script>alert("Você não tem permissões para aceder a esta area!"); location.href="'.PATH.'"; </script>';
}
$precat = BD::conn()->prepare("SELECT * FROM `filmes`");
$precat->execute();
?>
<title>IMM | Start</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
background: #030000;
}
.link{
color: #fff;
}
.link:hover{
text-decoration: underline;
color: #fff;
}
.background{
background: #e60002;
width: 100%;
}
.txt{
color: #fff;
}
div#filmes{
margin-left: 1px;
text-align: center;
margin-top: 5px;
}
div#barra{
border-top: 1px solid #000;
height: 42px;
width: 100%;
background: #e60002;
color: #fff;
}
.title{
text-align: center;
font-size: 28px;
}
.bk{
background: #000;
color: #fff;
}
.marg{
margin-left: 5px;
background:
}
.marg:hover{
background: red;
}
.mt{
margin-top: 5px;
}
</style>
</head>
<body>
<?php include_once "pages/menu.html"; ?>
<table class="mt">
<tr>
<?php while($res = $precat->fetchObject()){ ?>
<th><a class="link" href="<?php echo PATH; ?>detalhes/url/<?php echo $res->url; ?>"><img class="marg" width="264" height="351" src="<?php echo PATH; ?>thumbs/<?php echo $res->patch_thumb; ?>" /><br><?php echo $res->nome; ?></a></th>
<?php } ?>
</tr>
</table>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">IMM | START</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Desaja realmente terminar a sessão da IMM | START?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>
<button type="button" class="btn btn-primary" onclick="exit()">Sim, eu quero sair!</button>
</div>
</div>
</div>
</div>
<script src="<?php echo PATH; ?>js/jquery.js"></script>
<script src="<?php echo PATH; ?>js/bootstrap.min.js"></script>
</body>
</html>
For some reason he’s giving a kind of margin-top. And he doesn’t give the <br>
– Tomás Dinis
I’ve got the error, it has to do with the structure of the table, thanks for the help!
– Tomás Dinis
Actually what you have to do is generate the right table because if not it just creates column in the same row. The <br> example works: <?php $x = 0; $c = 0; while($x < 30){ echo 'FILM ' . $c . ' - '; if ($c <= 4) { $c++; } Else if ($c > 4) { echo '<br>'; $c = 0; } $x++; }
– rbz
Exactly. You need to loop the table, every 5 <td> you create a new <tr>.
– rbz
@Tomásdinis I put in your code.
– rbz
Thank you the page is already working correctly.
– Tomás Dinis