Codice PHP:
<?php
$limit = 5; // articoli per pagina
$mysql = new mysqli('localhost', 'root', '', 'html_it_articles');
if(!$mysql)
{
die("Errore di connessione al database, impossibile procedere");
}
$result = $mysql->query("SELECT COUNT(*) AS tot FROM articles")->fetch_assoc();
$page = isset($_GET['p']) ? $_GET['p'] : 1;
$totals = $result['tot'];
$totals_pages = ceil($totals / $limit);
$articles = $mysql->query("
SELECT
AR.id AS id,
AR.title AS title,
CONCAT(SUBSTR(AR.article, 1, 200), ' ...') AS content,
CONCAT(AU.surname, ' ', AU.name) AS author
FROM
articles AR,
authors AU
WHERE
AR.author_id = AU.id
ORDER BY id DESC
LIMIT ".(($page - 1) * $limit).",".$limit);
?>
<html>
<head>
<title>Articoli</title>
</head>
<body>
<ul>[*][url="index.php"]Lista articoli[/url][*][url="insert.php"]Inserisci un articolo[/url][/list]
Articoli totali: <?php echo $totals; ?></p>
<table width="500px">
<?php
while($article = $articles->fetch_assoc())
{
printf('<tr>
<td>%d. [url="show.php?id=%d"]%s[/url] (%s) </td>
</tr>
<tr>
<td>
%s</p></td>
</tr>
<tr>
<td><hr /></td>
</tr>',
$article['id'],
$article['id'],
$article['title'],
$article['author'],
$article['content']
);
}
?>
</table>
Pagina <?php echo $page; ?> di <?php echo $totals_pages; ?>
<?php
if($page - 1 > 0)
{
echo '[url="?p='.($page - 1).'"]< prev[/url] | ';
}else
{
echo '< prev | ';
}
if($page + 1 <= $totals_pages)
{
echo '[url="?p='.($page + 1).'"]next >[/url]';
}else
{
echo 'next >';
}
?>
</p>
</body>
</html>
vorrei utilizzare questo script per visualizzare i miei articoli inseriti nel mio db ma non so come devo modificarlo qualcuno mi può aiutare ? Riesco solo a far visualizzare il numero di articoli presenti ma non riesco a far visualizzare il resto