Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/06/2012, 12:39
Avatar de Zerquix18
Zerquix18
 
Fecha de Ingreso: junio-2012
Mensajes: 4
Antigüedad: 11 años, 10 meses
Puntos: 1
Dividir páginas de sistema de artículos

Hola, ando algo confundido. He creado un sistema de artículos para mi web pero quiero que cuando llegue a un máximo de 10 publicaciones aparezca debajo una división de páginas. No sé cómo hacerlo, estoy confundido.

http://zerquix18.no-ip.org/blog/ Es mi web con la página, si es necesario les paso los datos del artículo:

Cita:
<?php
$page = 'blog';
?>
<?php include "../docs/title.ini"; ?>
<?php include "../docs/head.ini"; ?>
<?php include "../docs/navegacion.ini"; ?>
<?php include "../docs/menu1.ini"; ?>
<?php include "../docs/menu2.ini"; ?>
<center>
<?php

include_once('_class/simpleCMS.php');
$obj = new simpleCMS();

$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = 'censurado.';
$obj->table = 'censurado';
$obj->connect();

if ( $_POST )
$obj->write($_POST);

echo ( $_GET['admin'] == 1 ) ? $obj->display_admin() : $obj->display_public();

?>
</center>
<?php include "../docs/pies.ini"; ?>
Y aquí el código de simpleCMS.php
Cita:
<?php

class simpleCMS {

var $host;
var $username;
var $password;
var $table;

public function display_public() {
$q = "SELECT * FROM testDB ORDER BY created DESC LIMIT 3";
$r = mysql_query($q);

if ( $r !== false && mysql_num_rows($r) > 0 ) {
while ( $a = mysql_fetch_assoc($r) ) {
$title = stripslashes($a['title']);
$bodytext = stripslashes($a['bodytext']);

$entry_display .= <<<ENTRY_DISPLAY
<h2><u>
$title
</u></h2>
<p>
$bodytext
</p>
<hr>

ENTRY_DISPLAY;
}
} else {
$entry_display = <<<ENTRY_DISPLAY

<h2> No hay entradas... </h2>
<p>
amm...
</p>

ENTRY_DISPLAY;
}
$entry_display .= <<<ADMIN_OPTION



ADMIN_OPTION;

return $entry_display;
}

public function display_admin() {
return <<<ADMIN_FORM

<form action="{$_SERVER['PHP_SELF']}" method="post">

<label for="title">Titulo:</label><br />
<input name="title" id="title" type="text" maxlength="150" />
<div class="clear"></div>

<label for="bodytext">Texto:</label><br />
<textarea name="bodytext" id="bodytext" cols="50" rows="5"></textarea>
<div class="clear"></div>

<input type="submit" value="Publicar" />
</form>

<br />

<a href="index.php">Volver al Inicio</a>

ADMIN_FORM;
}

public function write($p) {
if ( $_POST['title'] )
$title = mysql_real_escape_string($_POST['title']);
if ( $_POST['bodytext'])
$bodytext = mysql_real_escape_string($_POST['bodytext']);
if ( $title && $bodytext ) {
$created = time();
$sql = "INSERT INTO testDB VALUES('$title','$bodytext','$created')";
return mysql_query($sql);
} else {
return false;
}
}

public function connect() {
mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
mysql_select_db($this->table) or die("Could not select database. " . mysql_error());

return $this->buildDB();
}

private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS censurado (
title VARCHAR(150),
bodytext TEXT,
created VARCHAR(100)
)
MySQL_QUERY;

return mysql_query($sql);
}

}

?>
Por favor ayuda