Jump to content

[SOLVED] list LIMIT causing problems


jbingman

Recommended Posts

I have a LIMIT on an SQL statement that forces the user to click next/previous if content runs longer than 15. however, we have a copyright bar at the bottom of the page that doesnt show up until the last page of content. Does any one know why?

 

<?php
		// Determine startrow
	if (isset($_GET['startrow'])) {
		$startrow = $_GET['startrow'];
	} else {
		$startrow = 0;
	}

	$articlecount = "select id from main where section = '$section' and status != 'archive' and status != 'edit' AND status NOT LIKE '%f%'";
	$articlequery = @mysql_query($articlecount,$db_conn) or die(mysql_error());
	$articlenum = mysql_num_rows($articlequery);

	$listsql = "select id, monthname(date) as month, dayofmonth(date) as day, year(date) as year, section, date, title, writer from main where section = '$section' and status != 'archive'  and status != 'edit' AND status NOT LIKE '%f%' order by date desc LIMIT $startrow, 15";
	$listquery = @mysql_query($listsql,$db_conn) or die(mysql_error());
	$listnum = mysql_num_rows($listquery);

	while ($listrow = mysql_fetch_array($listquery, MYSQL_NUM)) {
		$lid = $listrow[0];
		$date = $listrow[1].' '.$listrow[2].', '.$listrow[3];
		$section = $listrow[4];
		$title = stripslashes($listrow[6]);
		$writer = stripslashes($listrow[7]);

		$listcont .= '<span class="regularindent"><a href="?page=articles&id='.$lid.'">'.$title.'</a> - '.$writer.' ('.$date.')<br></span>
';

	}

	echo '			<div id="sectionlistwrapper">

			Additional '.$section.' articles:<br>
			<br>
			'.$listcont;
		if ($articlenum > 15) {
			echo '					<span class="addlink">';

			if ($startrow >= 15) {
				echo '<a href="?page=section&section='.$section.'&startrow='.($startrow-15).'">< - previous</a> |';
			} else {
				echo '<span class="disabled">< - previous </span>|';
			}
			if ($startrow+15 < $articlenum && $articlenum > 15) {
				echo ' <a href="?page=section&section='.$section.'&startrow='.($startrow+15).'"> next - ></a>';
			} else {
				echo '<span class="disabled"> next - ></span>';
			}
			echo '</span>
';
		}

	echo "</div>
";
}


?>

Link to comment
https://forums.phpfreaks.com/topic/83509-solved-list-limit-causing-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.