All pastes #548566 Raw Copy code Copy link Edit

Casper

public unlisted php v1 · immutable
#548566 ·published 2007-06-07 19:36 UTC
rendered paste body
<?php/* Setting the page limit */$per_page = $news_limit;/* If underside is empty */if (empty($_GET["underside"])) {/* Then site will be 0 */$site = 0;}else {/* Else site will be $_GET["underside"] */$site = $_GET["underside"];}/* Selecting id from $news_table (nyheder) where limit is $site + $per_page ($news_limit) */$query = mysql_query("SELECT id FROM $news_tabel LIMIT ". ($site + $per_page) .",$per_page") or die(mysql_error());/* Gathering the number of rows in the mysql query ($query) above */$next_num = mysql_num_rows($query);/* If $site-$per_page is higher or equal to 0 */if (($site-$per_page) >= 0) {/* Creating a new mysql query */$query = mysql_query("select id from $news_tabel limit ". ($site - $per_page) .",$per_page");/* Gathering the number of rows in the mysql query ($query) above */$prev_num = mysql_num_rows($query);}else {$prev_num = 0;}/* Making a query that is used to display html */$sql = mysql_query("select * from $news_tabel ORDER BY $news_order_by DESC LIMIT $site,$per_page") or die(mysql_error());/* Making a div tag */echo "<div class=\"post\">";	// Settings	// int: Number of items on page	$pageLength = 3;	$currentPage = $_GET["underside"];		// Capture items in database	$totalNumberOfPosts = mysql_result(mysql_query("SELECT COUNT(id) AS total FROM $news_tabel"),0);		$currentPage = (int)$_GET['underside'];	$numberOfPages = ceil($totalNumberOfPosts/$pageLength);		// Generating links	$links = array();	$links[] = $currentPage - 1 > 0 ? "<a href=\"/archives/".($currentPage - 1)."\"><< Previous</a>" : '<< Previous';	for ($i=0;$i<$numberOfPages;$i++) {		// if current page == counter, add [].		$links[] = $currentPage == $i ? '<a href="/archives/'.$i.'">['.$i.']</a>' : '<a href="/archives/'.$i.'">'.$i.'</a>';	}	$links[] = $currentPage + 1 < $numberOfPages ? "<a href=\"/archives/".($currentPage + 1)."\">Next >></a>" : 'Next >>';	echo implode(' ',$links);/*Using the $sql to create the entrys and displaying it in html */while ($row = mysql_fetch_array($sql)) { ?>				<div class="header">					<h3><?php echo $row["overskrift"]; ?></h3>					<div class="date"><?php echo $row["dato"]; ?></div>				</div>				<div class="content">				<p>								<img src="<?php if ($row["blogimage"]) { echo "/$row[blogimage]"; } else { echo "/images/blogimages/na.JPG"; } ?>" class="floatleft" alt="Me" />								<?php 					/* Setting $content to $row["indhold"] */					$content = $row["indhold"];										/* Limiting the content to 240 signs with the php function www.php.net/substr */					$content = substr($content,0,240);										/* Setting three dots after the text */					$content = "$content...";										/* Stripping/adding stuff (like bbcode, smileys and more) to the content */					$content = strip_text($content);										/* Echoing content */					echo "$content";					/* Selecting comment number with mysql_query and mysql_num_rows */					$comment_number = mysql_query("SELECT * FROM kommentar WHERE nyhedsid = $row[id]") or die(mysql_error());				?></p>				</div>							<div class="footer">					<ul>						<li class="comments"><a href="/blogentry/<?php echo $row["id"]; ?>/#comments" target="_blank">Comments (<?php echo mysql_num_rows($comment_number); ?>)</a></li>						<li class="readmore"><a href="/blogentry/<?php echo $row["id"]; ?>/" target="_blank">Read more</a></li>						<li class="views"><a href="/blogentry/<?php echo $row["id"]; ?>/" target="_blank">(<?php if (!$row["views"]) { echo "0"; } else { echo $row["views"]; } ?>) views</a></li>						<li class="gototop"><a href="#top" title="Go to the top of the page">Top</a></li>					</ul>				</div>			<?php}	// Settings	// int: Number of items on page	$pageLength = 3;	$currentPage = $_GET["underside"];		// Capture items in database	$totalNumberOfPosts = mysql_result(mysql_query("SELECT COUNT(id) AS total FROM $news_tabel"),0);		$currentPage = (int)$_GET['underside'];	$numberOfPages = ceil($totalNumberOfPosts/$pageLength);		// Generating links	$links = array();	$links[] = $currentPage - 1 > 0 ? "<a href=\"/archives/".($currentPage - 1)."\"><< Previous</a>" : '<< Previous';	for ($i=0;$i<$numberOfPages;$i++) {		// if current page == counter, add [].		$links[] = $currentPage == $i ? '<a href="/archives/'.$i.'">['.$i.']</a>' : '<a href="/archives/'.$i.'">'.$i.'</a>';	}	$links[] = $currentPage + 1 < $numberOfPages ? "<a href=\"/archives/".($currentPage + 1)."\">Next >></a>" : 'Next >>';	echo implode(' ',$links);echo "</div>";?>