// how many rows we have in database
$query = "SELECT COUNT(id) AS numrows FROM art_content";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many rows to show per page
$rowsPerPage = 3;
$maxPage = ceil($numrows/$rowsPerPage);
$min = "1";
$max = $numrows;
$pageNum = rand($min,$maxPage);
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT id,articles,title FROM art_content LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
while($row = mysql_fetch_array($result))
{
$dbtitle = stripslashes($row['title']);
$replace = $artreplace;
$arttitle = str_replace($replace, "", $dbtitle);
$content .= "" . $arttitle . "
(Read More)
\n"; } randomrep ($content,'p',$rep120900); unset ($content);