Pulling information from a table to a news page

1

I have a news page that pulls by id (it's one of those noticias.php?id=1 ), but I wanted it to tell only the comments of the news I'm reading, not all of them. Is this possible?

I already got PHP to count, but I wanted to give this one specified.

PHP to count:

 <?php
 $contador = mysql_query("SELECT count(id) as total FROM 10cms_noticias_resp 
                         WHERE id_noticia = id_noticia") or die(mysql_error());

$comentario = mysql_fetch_assoc($contador);
 ?>
 <?php echo $comentario['total'];

  ?>

PHP from my page:

    $id = $_GET['id']; 
 $noticiass = mysql_query("SELECT * FROM 10cms_noticias WHERE id = $id") or die(mysql_error()); ?> 
 <?php $i = 0; while($edit = mysql_fetch_assoc($noticiass)){ $i++; ?>
    
asked by anonymous 26.07.2015 / 02:36

1 answer

4
   
$contador = mysql_query("SELECT count(id) as total FROM 10cms_noticias_resp 
                     WHERE id_noticia = id_noticia") or die(mysql_error());

This first clause WHERE is wrong. id_noticia will always be equal to itself.
You have to pass a value (or a variable) that corresponds to id of the news you want to consult.

    
26.07.2015 / 02:57