2
I am starting a code for a warehouse control using PHP and MYSQL, and when making a document of function separated from index.php and perform proper variable insertions via include duly stated in the head index.php and call the variable $columns, this does not return all the contents of my table in MYSQL, only repeats several times the first row of the table referred.
Follow the codes:
<!DOCTYPE html>
<html>
<head lang="pt-br">
<meta charset="UTF-8"/>
<link rel="stylesheet" href="css/estilo_alm.css"/>
<link onscroll="">
<title>index.php</title>
<?php include 'funcoes.php'; ?>
</head>
<body id="corpo">
<header id="cabecalho">
<h1>Projeto Almoxarifado ADVEC</h1>
<nav id="menuPags">
<ul type="disc">
<li><a class="pags" href="index.php">controle de material</a></li>
<li><a class="pags" href="controle_material.php">pedido de material</a></li>
<li><a class="pags" href="controle_notas.php">controle de notas</a></li>
<li><a class="pags" href="saida_material.php">saída de material</a></li>
</ul>
</nav>
</header>
<section id="titulo_principal">
<nav id="menuTabela">
<ul type="disc">
<li><a class="tabela" href="index.php">controle de material</a></li>
<li><a class="tabela" href="controle_material.php">pedido de material</a></li>
<li><a class="tabela" href="controle_notas.php">controle de notas</a></li>
<li><a class="tabela" href="saida_material.php">saída de material</a></li>
</ul>
</nav>
<div id="principal">
<table id="tabela2">
<?php
while($colunas): ?>
<tr>
<td id="td"><?php echo utf8_encode($colunas['idcidade']); ?></td>
<td id="td1"><?php echo utf8_encode($colunas['cidade']); ?></td>
<td id="td2"><?php echo utf8_encode($colunas['estado']); ?></td>
</tr>
<?php endwhile; ?>
</table>
</div>
</section>
<aside id="menuBotoes">
<ul type="disc">
<li><a class="botoes" href="index.php">controle de material</a></li>
<li><a class="botoes" href="controle_material.php">pedido de material</a></li>
<li><a class="botoes" href="controle_notas.php">controle de notas</a></li>
<li><a class="botoes" href="saida_material.php">saída de material</a></li>
</ul>
</aside>
<footer id="rodape">
</footer>
<?php $conecta->close(); ?>
</body>
</html>
<!DOCTYPE html>
<html>
<head lang="pt-br">
<meta charset="UTF-8"/>
<title>funcoes_almox.php</title>
</head>
<body>
<?php
define("SERVIDOR", "localhost");
define("USUARIO", "root");
define("SENHA", "");
define("BANCODEDADOS", "controle_almoxarifado_v02");
$conecta = new mysqli(SERVIDOR, USUARIO, SENHA, BANCODEDADOS);
if ($conecta->connect_error) {
trigger_error("ERRO NA CONEXÃO: " . $conecta->connect_error, E_USER_ERROR);
}
$selecao_geral = mysqli_query($conecta, 'select * from cidade');
$colunas = $selecao_geral->fetch_assoc();
?>
</body>
</html>
Put include before doctype
– BackFront
I put it but it didn’t work any other way.
– Jonas Soares
First, why are you creating a document
html
no include?– Jorge.M
Oops! Even with HTML body the document is php, but as it was the first time I posted something here and I have no experience in posting code, I was not able to put only php of funcoes_almox.php and as I saw that the code of index.php entered, put equal.
– Jonas Soares