All pastes #632636 Raw Edit

Stuff

public text v1 · immutable
#632636 ·published 2007-07-25 00:56 UTC
rendered paste body
####################################################################### PHP
Offset: -25
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 '-25, 25' at line 1
####################################################################### PHP
function listUsers() {
$entries_per_page = 25;
	$result = mysql_query("SELECT COUNT(*) AS user_id FROM users") or die(mysql_error());
	$row = mysql_fetch_row($result);
	$total_entries = $row[0];
	if(isset($_GET['page'])) {
		$page = $_GET['page'];
	} else {
		$page = 1;
	}
	$total_pages = ceil($total_entries / $entries_per_page);
	$offset = ($page - 1) * $entries_per_page;
	echo "Offset: " . $offset . "<br />";
	$result = mysql_query("SELECT * FROM users LIMIT $offset, $entries_per_page") or die(mysql_error());
	echo "<ul>";
	while($row = mysql_fetch_object($result)) { 
		echo "<li>";
		echo $row['user_name'];
		echo "</li>";
	}
	echo "</ul><br />";
	for($i = 1; $i <= $total_pages; $i++) {
		if($i == $page) { 
			// This is the current page. Don't make it a link. print "$i "; 
			echo $i . "(Current page)";
		} else { 
			// This is not the current page. Make it a link. print " <a href="products.php?page_number=$i">$i</a> "; 
			if ($url_rewrite) {
				$link = $system['home'] . "admin/users/page/" . $i;
			} else {
				$link = $system['home'] . "admin.php?page=users&page=" . $i;
			}
			echo "<a href=\"" . $link . "\">Page " . $i . "</a>";
		}
	}
}