SQL / PHP Query

0

I am trying to query the database in 2 tables and pull the data to page with a condition would be this if the id_noticia of a table is equal to the id of the other when clicking on the image or name goes redirects to the page of the news according to the id but it works out would like a help if possible

<?php    

 $pagCorrente = 1;
 if(isset($_GET['pag'])){
     $pagCorrente = (int)$_GET['pag'];
 }
 $mostrar = 10;

 $pagCorrente = $pagCorrente * $mostrar - $mostrar;

 $sqlTotal = "SELECT count(id) as total FROM noticia0;";     
 $ex = $conexao->query($sqlTotal);  
 $total = mysqli_fetch_object($ex);  
 $total = $total->total;

 $quantPages = ceil($total / $mostrar);

 $sql = "    SELECT COUNT(*) FROM noticia0 n, noticia nn
     WHERE n.id_noticia = nn.id   
     ORDER BY n.id desc LIMIT $pagCorrente,$mostrar";
 $wx = $conexao->query($sql);

 while($linha = mysqli_fetch_object($wx)){

 ?>

<div class='div0'>
<a href="<?php echo SITE;?>noticia3.php?id=<?php echo $linha->id; ?>">
 <div class='pa'>
      <img src='<?php echo SITE . 'php/upload/' . $linha->imagen2;?>' />
  </div>

   <div class='po'>
   <p>
     <br><?php echo $linha->titulo;?></br>
     <br><?php echo $linha->sinopse;?></br>
    
asked by anonymous 29.01.2018 / 18:17

1 answer

0

In your query, you are doing SELECT COUNT(*) , it is the only thing that is returning in your object, change by its alias n.* , nn.* that you will have the result of your query. If I have not understood very well, post what the error is going on.

Abs.

    
29.01.2018 / 18:42