I'm trying to make a project HTML
with PHP
and while I was developing it locally it was great, once I uploaded it to the server I had several problems, for example:
I have a page "index-mercadeo.php"
that performs a query by ajax to show a dynamic table. However, when I uploaded the page to the server, the table remains empty, it apparently has no errors.
I leave the code - > index-marketing.php
<?php
session_start();
if(!isset($_SESSION["usuario"])){
header("Status: 301 Moved Permanently");
header("Location:index.php");
echo"<script language='javascript'>window.location='index.php'</script>;";
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Mercadeo</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Plugin CSS -->
<link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template -->
<link href="css/freelancer.min.css" rel="stylesheet">
<link href="css/form.css" rel="stylesheet">
<!-- FAVICON IMG -->
<link rel="shortcut icon" href="img/favico.png">
<!-- Elements AJAX -->
<script src="js/obtener_ajax.js"></script>
</head>
<body id="page-top">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg bg-secondary fixed-top text-uppercase" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top">Sistema Inventario</a>
<a href="do_logout.php" title="Salir"><img style="height: 60px; width: 60px;" src="img/salir-opcion.png"></a>
</div>
</nav>
<!-- Header -->
<div class="container" style="padding-top: 50px"></div>
<!-- Section -->
<section id="ubicacion.php">
<div class="container">
<span>"Usuario : <?php echo $_SESSION["usuario"] ?>"</span><br><span>"Fecha: <?php echo date('d/m/Y') ?>"</span>
<div class="container" style="padding-top: 50px"></div>
<form class="form-basic" id="fcrear">
<div class="form-title-row">
<h1>Realizar Inventario</h1>
</div>
<div class="container">
<div class="form-row">
<label class="control-label" style="padding: 10px">Canal</label>
<div class="controls">
<select name="canal" onclick="obtenerRz(this.value)" onchange="obtenerRz(this.value)" required="true" >
<?php
include 'conexion.php';
$pdo = Database::connect();
$sql = "SELECT DISTINCT nom_canal FROM ubicacion";
foreach ($pdo->query($sql) as $row) {
echo '<option value="'. $row['nom_canal'] .'" >'. $row['nom_canal'] .'</option>';
}
Database::disconnect();
?>
</select>
</div>
</div>
<div class="form-row">
<label class="control-label" style="padding: 10px">Razon Social</label>
<div class="controls">
<div id="error"></div>
<div id="Rz"></div>
</div>
</div>
<div class="form-row">
<label class="control-label" style="padding: 10px">Sucursal</label>
<div class="controls">
<div id="errorSc"></div>
<div id="Sucursal"></div>
</div>
</div>
</form>
</div>
</section>
<!-- SECCION LISTA DE PRODUCTOS -->
<!-- Section -->
<section>
<div class="container">
<h2 class="text-center text-uppercase text-secondary mb-0">Inventario</h2>
<div class="container" style="padding-top: 50px"></div>
<div class="row">
<div class="col-lg-8 mx-auto">
<!-- TABLE-->
<div id="errorProducto"></div>
<div id="Productos"></div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<div class="copyright py-4 text-center text-white">
<div class="container">
<img class="img-fluid mb-5 d-block mx-auto" src="img/footer-logo.png">
<small>Copyright © 2018 - Todos los derechos reservados</small>
</div>
</div>
<!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) -->
<div class="scroll-to-top d-lg-none position-fixed ">
<a class="js-scroll-trigger d-block text-center text-white rounded" href="#page-top">
<i class="fa fa-chevron-up"></i>
</a>
</div>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Plugin JavaScript -->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="vendor/magnific-popup/jquery.magnific-popup.min.js"></script>
<!-- Custom scripts for this template -->
<script src="js/freelancer.min.js"></script>
</body>
</html>
- > optenerProductos.php [Where the dynamic table is generated by ajax.]
<?php
if (!empty($_GET['nom_canal']) && !empty($_GET['nom_rz']) && !empty($_GET['ide_sucursal'])) {
$nom_canal = $_REQUEST['nom_canal'];
$nom_rz = $_REQUEST['nom_rz'];
$ide_sucursal = $_REQUEST['ide_sucursal'];
}
?>
<form name="sentMessage" id="contactForm" novalidate="novalidate" action="actualizarInventario.php" method="post">
<table class="table table-hover">
<thead>
<tr>
<th bgcolor="#f5f3f3">ID Ubicacion</th>
<th>Producto</th>
<th>ID Producto</th>
<th>Estado</th>
<th>Historico</th>
<th bgcolor="#f5f3f3">Inventario</th>
</tr>
</thead>
<tbody>
<?php
include 'conexion.php';
$pdo = Database::connect();
$sql = "SELECT * FROM productos WHERE estado_producto = 'ACTIVO' AND ide_canal = (SELECT ide_canal FROM ubicacion WHERE nom_canal = '".$nom_canal."' AND nom_rz = '".$nom_rz."' AND ide_sucursal = '".$ide_sucursal."' ) ";
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
echo '<td bgcolor="#f5f3f3" >'. $row['ide_canal'] . '</td>';
echo '<td>'. $row['nom_producto'] . '</td>';
echo '<td>'. $row['ide_producto'] . '</td>';
echo '<td>'. $row['estado_producto'] . '</td>';
echo '<td>'. $row['historico'] . '</td>';
echo '<td><input class="form-control" type="number" placeholder="0" name = "inventario[]" required="required" ></td>';
echo '<td><input type="hidden" value="'. $row['ide'] .'" name="ideProducto[]"></div></td>';
echo '</tr>';
}
Database::disconnect();
?>
<div ></div>
</tbody>
</table>
<br>
<div id="success"></div>
<div class="form-group" align="center">
<button type="submit" class="btn btn-primary btn-xl" id="sendMessageButton">Enviar Reporte</button>
</div>
</form>
Here is the sample of how the page is once I call the table:
The header of the table is created correctly and as seen in the image, the <tbody>
closes with </tbody>
so it would not know if it is an error or that it does not execute the query.
but I've already tried the query in the database and it works.
BD query:
<?php
include 'conexion.php';
$pdo = Database::connect();
$sql = "SELECT * FROM productos WHERE estado_producto = 'ACTIVO' AND ide_canal = (SELECT ide_canal FROM ubicacion WHERE nom_canal = '".$nom_canal."' AND nom_rz = '".$nom_rz."' AND ide_sucursal = '".$ide_sucursal."' ) ";
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
echo '<td bgcolor="#f5f3f3" >'. $row['ide_canal'] . '</td>';
echo '<td>'. $row['nom_producto'] . '</td>';
echo '<td>'. $row['ide_producto'] . '</td>';
echo '<td>'. $row['estado_producto'] . '</td>';
echo '<td>'. $row['historico'] . '</td>';
echo '<td><input class="form-control" type="number" placeholder="0" name = "inventario[]" required="required" ></td>';
echo '<td><input type="hidden" value="'. $row['ide'] .'" name="ideProducto[]"></div></td>';
echo '</tr>';
}
Database::disconnect();
?>
Thank you.
EDICIO
Other tables if they are created dynamically.