All pastes #640631 Raw Edit

Untitled

public php v1 · immutable
#640631 ·published 2007-07-31 15:15 UTC
rendered paste body
<?phpinclude("config.php");   $limit      = 1;                   // Sets how many results shown per page        $query_count    = "SELECT count(*) FROM articles";        // Sets what we want to pull from the database    // count(*) is better for large databases (thanks Greg!)        $result_count   = mysql_query($query_count);        // Pulls what we want from the database        $totalrows  = mysql_num_rows($result_count);        // This counts the number of users 		if(empty($page)){    // Checks if the $page variable is empty (not set)        $page = 1;      // If it is empty, we're on page 1    }    $limitvalue = $page * $limit - ($limit);  $article = mysql_query("SELECT *  FROM `articles` LIMIT $limitvalue, $limit");$check = mysql_num_rows($article); $totalrows = $check;if ($check < 1) {	echo "no rows";}	else {while($row = mysql_fetch_array($article)) {	$title = $row['title'];	$short = $row['short'];	$full = $row['full'];	$comments = $row['comments'];	echo "\n\n<div class=\"container\">\n<div class=\"title\"><a href=\"full.php?id=".$row['id']."\">" . $title . "</a></div>\n";	echo $short;	if($short != $full) { echo "..<br /><a href=\"full.php?id=".$row['id']."\">Read More</a>";	}	if ($comments != 0) {	echo "<br /><a href=\"full.php?id=".$row['id']."\">$comments comments</a></strong>";	}	echo "</div><br /><br />\n\n";	    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);     } 	    } }?>