Need Help Paging in PHP
Posted: Tue May 23, 2006 6:06 pm
Hello,
I need help with php paging system the code below is my index.php and it didnt work properly so i had to revert back to my old index.php which has no paging. The problem occurs after i include the line it gives me mysql function errors of mysql_fetch_assoc and mysql_fetch_row, i took out that line to get rid of the errors then the for loop started giving me parse errors its says that i am missing ";" in the script and if i add the script it says unexpected ";" in the script expecting ")" can someone please help me with this or give me a php paging script because i WILL go crazy over this thing i gave up after about 2days of trying STRAIGHT lol
Thanks for your Help
I need help with php paging system the code below is my index.php and it didnt work properly so i had to revert back to my old index.php which has no paging. The problem occurs after i include the line
Code: Select all
$num_page = mysql_fetch_row($result);Thanks for your Help
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p><a href="add_news.php">Click Here to add news<br />
</a><a href="news_view.php">Click Here to edit news </a></p>
<p>
<?
$dbh=mysql_connect ("localhost", "$user", "$pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$db");
$page_limit = 2;
$page_offset += $page*page_limit;
$result = mysql_query("SELECT `newsID`, `news`, `Title` FROM `news`
ORDER BY `newsID` DESC LIMIT ($page_offset-1), ($page_limit)");
while($record = mysql_fetch_assoc($result)){
$Title = $record['Title'];
$news = $record['news'];
$id = $record['newsID'];
echo "<table width='600' border='0'>
<tr>
<td><div style='border-top:1px solid #000000 '><strong>$Title</strong></div>
<div style=' border-bottom:1px solid #000000;'>$news</div>";
$resultx = mysql_query("SELECT count(comments.commentid
AND comments.newsID)
FROM comments
WHERE comments.newsID = '".$id."'
ORDER BY comments.commentid ASC ");
while($row1 = mysql_fetch_row($resultx)){
echo "<div style='border-bottom:1px solid #000000; '><a href='comments.php?newsID=".$record['newsID']."'>Comments($row1[0])</a></div>
<BR><BR>";
}
echo "</td>
</tr>
</table>";
}
$query3 = "SELECT COUNT(news.newsID AND news.Title AND news.news) AS numrows FROM news";
$result3 = mysql_query($query3) or die('Error, query failed' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$num_page = mysql_fetch_row($result)
for($i = 1; $i <= $num_page; i++){
echo "<a href='www.lod-gaming.net/work/?page=$i'>$i</a>";
?>
</p>
<p> </p>
</body>
</html>