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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.