0
In this script, it is limited to the display of 6 queries in the SELECT variable $quantidade_pg = 6, I used the IF to inform that all news situations other than 2 (unpublished) should be displayed.
The detail is that in my SELECT, in order of creation from the latest to the oldest, the detail is that when limiting 6 news, and is with the oldest date does not display these news.
Example: I have a total of 10 news, 1 per week, but the last 6 news is displayed in order of the most recent the oldest, but when unpublishing 6 news, in the middle weeks, leaving the 2 latest news and the 2 latest news, should be shown, but in this script only displays the latest 2 not displaying the older ones. It seems that IF is limited to SELECT, and I understand that it has 6 queries.
I searched the net to limit in while or Aldo type, or INNER JOIN in SELECT.
Someone could help me.
I have this code:
$pagina = (isset($_GET['pagina']))? $_GET['pagina'] : 1;
//Selecionar os noticias a serem apresentado na página da mais recente a antiga
$result_noticias = "SELECT * FROM noticias ORDER BY created DESC";
//Selecionar os noticias a serem apresentado na página
$resultado_noticias = mysqli_query($conn, $result_noticias);
//Contar o total de noticias
$total_noticias = mysqli_num_rows($resultado_noticias);
//Seta a quantidade de noticias por pagina
$quantidade_pg = 6;
//calcular o número de pagina necessárias para apresentar os noticias
$num_pagina = ceil($total_noticias/$quantidade_pg);
//Calcular o inicio da visualizacao
$incio = ($quantidade_pg*$pagina)-$quantidade_pg;
//Selecionar os noticias a serem apresentado na página
$result_noticias = "SELECT * FROM noticias ORDER BY created DESC limit $incio, $quantidade_pg";
$resultado_noticias = mysqli_query($conn, $result_noticias);
$total_noticias = mysqli_num_rows($resultado_noticias);
<?php while($row_noticias = mysqli_fetch_assoc($resultado_noticias)){?>
">
But in my bank I have the news table and the column situaca_noticia_id (id1/id2).
I have the other table situaca_noticia, in it the columns (id/name), thus
(id1/published)-(id2/unpublished).
I would like when the ID is 2 (not published), not to show the news at while.
My knowledge is lacking.
If you have a foreign key of the news table in the table situacao_noticia you could use an INNER in the query and only return what did not have the ID 2.
– KillerJack