Jump to content

Next page...code


truepal20032001

Recommended Posts

Hello, i am very interested in php, and had started creating my first codes, but i have a simple question i want to apply to my website....
something like this...

[img]http://www.coronadosoccer.com/my_docs/help.jpg[/img]

the website i am talking about is [url=http://www.coronadosoccer.com/home]www.coronadosoccer.com/home[/url]
thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/35176-next-pagecode/
Share on other sites

I think what you want to look into is called pagination. Though pagination usually occurs when you either have too many results of a search to display on one page or you are progressing a user through a site in a very systematic way. You should post your site URL and explain what type of pagination you need.
Link to comment
https://forums.phpfreaks.com/topic/35176-next-pagecode/#findComment-166117
Share on other sites

[code] <?php
if ($_GET['rownumberprev']) {
$rownumber = mysql_real_escape_string($_GET['rownumberprev']);
}elseif ($_GET['rownumbernext']) {
$rownumber = mysql_real_escape_string($_GET['rownumbernext']);
}else {
$rownumber = 0;
}
$limit = 20;
// get total amount of rows in database
$year = date("Y");
$month = date("n");
$selecttemp = "SELECT * FROM specialimagesystem;";
$querytemp = mysql_query($selecttemp);
$total_rows = mysql_num_rows($querytemp);
// get current year and date, for use with query
$select1 = "SELECT * FROM specialimagesystem LIMIT $rownumber, $limit;";
$query1 = mysql_query($select1);
while ($row1 = mysql_fetch_array($query1)) {
echo "<div class=\"specialimagesystem\">\n";
$target = "/specialimages/";
$width = "100px";
$height = "100px";
echo "<a href=\"{$target}{$row1[name]}\" class=\"thickbox\" title=\"{$row1[description]}\" rel=\"gallery1\"><img src=\"{$target}{$row1[name]}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$row1[name]}\" /></a>";
echo "<span style=\"float:left;\">"; // starts span for price and id
echo $row1['description'];
echo "<br />";
if ($row1['price'] != "") { // if price is set, then show it
echo "Price: $" . $row1['price'];
echo "<br />";
}// either way show the id
echo "ID: " . $row1['id'];
echo "</span>";
echo "<br /></div>\n";
}
?>
</div>
<div class="pag">
<?php
// pagination script part down here
if ($rownumber != 0) {
$rownumberprev = $rownumber - $limit;
echo "<a href=\"totalinventorypictures.php?rownumberprev={$rownumberprev}\">Previous Page</a>";
echo "<br />";
}
if ($rownumber <= ($total_rows - $limit)) {
$rownumbernext = $rownumber + $limit;
echo "<a href=\"totalinventorypictures.php?rownumbernext={$rownumbernext}\">Next Page</a>";
}
?>
</div>[/code]

Just a quick example of how I normally do pagination, to give you something to look out too.
Link to comment
https://forums.phpfreaks.com/topic/35176-next-pagecode/#findComment-166154
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.