I hope they are fine.
I have the following query:
finished.php file
$fechatwo=$_GET['fecha'];
$limit = '3';
$page = 1;
if($_POST['page'] > 1)
{
$start = (($_POST['page'] - 1) * $limit);
$page = $_POST['page'];
}
else
{
$start = 0;
}
$query = "
SELECT * FROM trabajos WHERE estado_kal='Finalizado' AND fecha_fin='$fechatwo'
";
if($_POST['query'] != '')
{
$query .= '
AND equipo_kal LIKE "%'.str_replace(' ', '%', $_POST['query']).'%"
';
}
$query .= 'ORDER BY reporte_kal DESC ';
$filter_query = $query . 'LIMIT '.$start.', '.$limit.'';
$statement = $connect->prepare($query);
$statement->execute();
$total_data = $statement->rowCount();
$statement = $connect->prepare($filter_query);
$statement->execute();
$result = $statement->fetchAll();
$total_filter_data = $statement->rowCount();
The problem is that my variable $datetwo=$_GET['date']; does not bring data or the query does not want to take data from that variable.
I do the following exercise: $datetwo='2020-06-01'; and if it works fine.
What could be wrong in the code?
I edit my question:
Here I have the index.php
I get the data there:
$fechatwo=$_GET['fecha'];
<div class="form-group">
<input type="text" name="search_box" id="search_box" class="form-control" placeholder="Buscador (Equipo)" autocomplete="off" />
</div>
<div class="table-responsive" id="dynamic_content">
</div>
<script>
$(document).ready(function(){
load_data(1);
function load_data(page, query = '')
{
$.ajax({
url:"finalizados.php",
method:"POST",
data:{page:page, query:query},
success:function(data)
{
$('#dynamic_content').html(data);
}
});
}
$(document).on('click', '.page-link', function(){
var page = $(this).data('page_number');
var query = $('#search_box').val();
load_data(page, query);
});
$('#search_box').keyup(function(){
var query = $('#search_box').val();
load_data(1, query);
});
});
</script>
and through javascript I bring the finished.php file
You are POSTing
finalizados.php
but assuming the GET persists from page to page.$_GET
is an array of the parameters that arrive in the URL (egfinalizados.php?fecha=20201231&var1=test
). If the index receives that, it does not mean that it will be sent to the others.when you do
the URL is
http://alguna/ruta/finalizados.php
and there is no parameter in the GET. The scriptfinalizados.php
has no idea what it receivedindex.php
. And ditto,index.php
it doesn't pass the entire variable contextfinalizados.php
to unless you do it explicitly.For what you are looking for, you would have to include
$fechatwo
within what you give tofinalizados.php
:finalizados.php?fecha=$fechatwo
) or