Arez Posted June 3, 2006 Share Posted June 3, 2006 Here is my current code[code]// this function views logsfunction viewLogs() {global $bordercolor1, $tablebg1;echo "<table align='center' border='1' bordercolor='$bordercolor1' cellspacing='0' cellpadding='0' width='550'><tr><td class='main' background='$tablebg1'><center><b>View Logs</b></center></td></tr><tr><td class='small'><br><blockquote>";$query = "SELECT * FROM log ORDER BY id DESC";$result = mysql_query($query) or die("error");while($row = mysql_fetch_array($result)){extract($row);echo "<b>Date:</b> $date1<br><b>Action:</b> $action<br><b>Reason:</b> $reason<br><hr size='1' width='500' color='$bordercolor1'><br>";}$limit = 25; $query_count = "SELECT count(*) FROM table"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM table LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor.">n<td>"); echo($row["users"]); echo("</td>n<td>"); echo($row["usersID"]); echo("</td>n</tr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); } mysql_free_result($result);echo "</blockquote></td></tr></table>";} // end viewLogs function[/code]And it gives me -Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'table LIMIT 0, 25' at line 1it says that near the bottom of the logs. What'd I do wrong? Link to comment https://forums.phpfreaks.com/topic/11103-pagination-not-working/ Share on other sites More sharing options...
sasa Posted June 4, 2006 Share Posted June 4, 2006 change[code]table[/code]to[code]`table`[/code]So there's no confusion ... change that in the query. Link to comment https://forums.phpfreaks.com/topic/11103-pagination-not-working/#findComment-41664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.