Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

giovanivargas

Paginação em php

Recommended Posts

Bom estou com um problema como posso fazer um paginação usando o sistema mvc. Ai esta algumas partes:

 

NOTICIADAO

} 	public function getNoticia($inicio, $quantidade){
	$sql = "select * from noticia ORDER BY id DESC LIMIT '$inicio', '$quantidade' ";
	$consulta = $this->conexao->query($sql);
	$noticia = $consulta->fetchAll(PDO::FETCH_CLASS, 'Noticia');
	return $noticia;
}

NOTICIACONTROLLER

	case 'listar':
		$pg = $_GET["pg"];
		 if(isset($pg)){
			 $pg = $pg;
			 }else{
				 $pg = 1;
				 }
		 $quantidade = 3;
		 $inicio = ($pg*$quantidade) - $quantidade;
		$dao2 = new NoticiaDAO;
		$noticia = $dao2->getNoticia($inicio, $quantidade);
		if(count($noticia)==0){
			$_SESSION['mensagem']=htmlentities('Não há noticias cadastradas!');
			header('location:../gui/GuiMensagem.php');
		}else{
			$_SESSION['s_noticia']=serialize($noticia);
			header('location:../Noticias.php');
		}
	break;

NOTICIAS.PHP

//onde sera exibida todas as noticias.

     <?php

if(isset($_SESSION['s_noticia'])){
include 'classes/Noticias.class.php';
$noticia = unserialize($_SESSION['s_noticia']);

	foreach($noticia as $n2){ 
		 	 echo '</br><hr></br>';		
	echo "<img src='fotos/".$n2->imagem."'width=150 height=100>";
    echo ' <div class="publicacao"><strong>Publicação: </strong>' . $n2->data . '</div></hr>' . 
		 '<div class="titulo"><b>' . $n2->titulo . '</b></div>' .
		 '<div class="texto"><p> ' . $n2->texto . '</p></br></div></hr>' ;	         		
	}
}else
	header('location:controle/ControleNoticias.php?operacao=listar');	 
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.