I'm trying to make a list that shows clients number of log ins and the last date they did. but i'm getting a error:
Warning: Invalid argument supplied for foreach() in /i/changedthis part/clientes/mostrarClentesLogin.php on line 37
my code for line 37 and the SQL query are:
<?php function listaClientes($lclientes) {
$codigo = '<table id="adminTable" border="1" cellpadding="10">';
$codigo .= '<tr>
<th>RFC</th>
<th>Razón Social</th>
<th>Número de Entradas</th>
<th colspan="2">Fecha de la última entrada</th>
</tr>';
foreach ($lclientes as $fila) {
$codigo .= '<tr>';
$codigo .= '<td>' . $fila["rfc"];
$codigo .= '<td>' . $fila["razonSocial"];
$codigo .= '<td>' . $fila["numeroEntradas"];
//$codigo .= '<td class="center"><a href="borrarCliente.php?id=' . $fila["idDATOS_CLIENTE"] . '">Borrar</a></td>';
$codigo .= '<td>' . $fila["fechaUltimoACCeso"];
$codigo .= '</tr>';
}
$codigo .= '</table>';
return $codigo; } ?> <?php
$page = 1;
if(array_key_exists('pg', $_GET)){
$page = $_GET['pg'];
}
$query = "SELECT COUNT(*) AS conteo FROM DATOS_CLIENTE";
$conteo = new classConexion($hostname, $usuarioDB, $passwordDB, $database);
$num = $conteo->enviarQuery($query);
foreach ($num as $totalRegistros){
$totalRegistros = $totalRegistros["conteo"];
}
//$max_numero_paginas = intval($totalRegistros/4);
if($totalRegistros/15>intval($totalRegistros/15)){
$max_numero_paginas = intval($totalRegistros/15)+1;
}
else{
$max_numero_paginas = intval($totalRegistros/15);
}
$query = ("SELECT `DATOS_CLIENTE`.`rfc` , `DATOS_CLIENTE`.`razonSocial` , `USUARIOS`.`numeroEntradas` , `USUARIOS`.`fechaUltimoAcceso` FROM DATOS_CLIENTE INNER JOIN USUARIOS WHERE `DATOS_CLIENTE`.`USUARIOS_idCLIENTES` = `USUARIOS`.`idCLIENTES` LIMIT". (($page-1)*15).", 15");
$mostrarClientes = new classConexion($hostname, $usuarioDB, $passwordDB, $database);
$clientes = $mostrarClientes->enviarQuery($query);
print listaClientes($clientes);
for ($i=0;$i<$max_numero_paginas;$i++){
echo '<a href="clientes.php?pg='.($i+1).'">'.($i+1).'</a> | ';
}
?>
</section>
when i run the query in phpMyAdmin its works fine and shows the info right but i think my mistake its in the formatting when i try to print it in the page, with var_dump($lclientes) i get NULL, how can i can retreive the correct records of my DB