0
What I’m doing wrong in this script?
I make a query in the database to return all table data curso
and show their names in the table, but it’s not working.
Also this part of the code is being shown on the page:
(prepare("SELECT * FROM curso"); if($consulta->execute()){ ?>
fetch(PDO::FETCH_OBJ)){ ?> '.$dados->idCursoLi . ''; echo ''; echo ''; } }?>
'.$dados->nomeCursoLi . '
My code:
<?php
require '../conexao/conexao_BD.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>Painel</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<!-- styles -->
<link href="../css/styles-Painel.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-5">
<!-- Logo -->
<div class="logo">
<h1><a>Painel do Administrador</a></h1>
</div>
</div>
<div class="col-md-2">
<div class="navbar navbar-inverse" role="banner">
<nav class="collapse navbar-collapse bs-navbar-collapse navbar-right" role="navigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Minha Conta<b class="caret"></b></a>
<ul class="dropdown-menu animated fadeInUp">
<li><a href="logout.php">Sair</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
<div class="page-content">
<div class="row">
<div class="col-md-2">
<div class="sidebar content-box" style="display: block;">
<ul class="nav">
<!-- Main menu -->
<li class="current"><a href="painel.html"><i class="glyphicon glyphicon-home"></i> Home</a></li>
<li class="submenu">
<a href="#">
<i class="glyphicon glyphicon-list"></i> Administrador
<span class="caret pull-right"></span>
</a>
<!-- Sub menu -->
<ul>
<li><a href="cadastrarAdm.html">Cadastrar</a></li>
<li><a href="#">Editar</a></li>
<li><a href="#">Remover</a></li>
</ul>
</li>
<li class="submenu">
<a href="#">
<i class="glyphicon glyphicon-list"></i> Curso
<span class="caret pull-right"></span>
</a>
<!-- Sub menu -->
<ul>
<li><a href="cadastrarCurso.html">Cadastrar</a></li>
<li><a href="#">Editar</a></li>
<li><a href="#">Remover</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<table class="table-bordered">
<h2>Cursos cadastrados</h2>
<?php $consulta = $PDO->prepare("SELECT * FROM curso");
if($consulta->execute()){ ?>
<table class="table table-bordered">
<thead>
<tr>
<th>Curso</th>
<th>Excluir</th>
</tr>
</thead>
<?php while($dados = $consulta->fetch(PDO::FETCH_OBJ)){ ?>
<tr>
<?php echo '<td>'.$dados->idCursoLi . '</td>';
echo '<td>'.$dados->nomeCursoLi . '</td>';
echo '<td><a href="deletarCurso.php?id='.$dados->idCursoLi.'"><img src="delete.png" alt="Excluir curso" height="42" width="42"></a></td>';
} }?>
</tr>
</table>
</div>
<footer>
<div class="container">
<div class="copy text-center">
Copyright(@) <a href="inove.html">Inove.</a> Desenvolvido por: <a target="blank_" href="http://tecnosystemej.com/site/">Tecno System</a>
</div>
</div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/custom.js"></script>
</body>
</html>
Hi, thanks! I managed to fix, had two <table> tags, deleted and went! But this way you did using Expression Language is a good option for those who do not want to merge HTML cm PHP like I did.
– Isadora Almeida