Limit Display Posts

is there anyway to limit the number of posts displayed?

[code]<?php
$sql = “SELECT * FROM forum”;
$result = $mysqli->query($sql);

while($row = $result->fetch_assoc()) {
echo $row[‘user’].’, ‘.$row[‘date’].’
‘;
echo $row[‘message’].’
’;
echo '------------------------
';
}
?>[/code]

A limit clause in the query does that.

how owuld i use limit and make it for the latest rows and not the first ones?

Last rows indicates an order by.

What is the table structure?

SELECT columns FROM table ORDER by primary_key DESC LIMIT 10

Sponsor our Newsletter | Privacy Policy | Terms of Service