This is enhancement of Page Scroller ver 2, I add a page map link so you can jump to any page.
By : wibi
<?
/********************************************************************
* page scroller code snippet.
*
* Copyright (C) 2001 Wibisono Sastrodiwiryo.
* This program is free software licensed under the
* GNU General Public License (GPL).
*
* CyberGL => Application Service Provider
* http://www.cybergl.co.id
* office@cybergl.co.id
*
* $Id: scroller3.php3,v 0.3 2001/06/18 13:28:30 wibi Exp $
*********************************************************************/
#---------------------------------------database configuration
$db_user = "root";
$db_pass = "pass";
$db_name = "phpMember";
$db_host = "localhost";
mysql_pconnect($db_host, $db_user, $db_pass) or die("Unable to connect to SQL server");
mysql_select_db($db_name) or die("Unable to select database");
#---------------------------------------page scroller configuration
$script="scroller3.php3";
$offset+=0;
$item_perpage= 2; #----change this to define how many item per page
$prev= $offset-$item_perpage;
$next= $offset+$item_perpage;
#---------------------------------------query configuration
$tbl_search = "country";
$field="name ";
$query="SELECT $field FROM $tbl_search WHERE $field LIKE '%$keyword%' LIMIT $offset, $item_perpage";
$querytotal="SELECT count(*) FROM $tbl_search WHERE $field LIKE '%$keyword%'";
$total=mysql_fetch_row(mysql_query($querytotal));
#----modify the where clause to fit your query need
#---------------------------------------page map
$pages = (int) ($total[0] / $item_perpage);
if ($total[0] % $item_perpage) {$pages++;}
for ($a=1;$a<=$pages;$a++) {
$map[$a] =" <a href=\"$script?offset=$offset2&keyword=$keyword\">$a</a> ";
$offset2+=$item_perpage;
}
$pagemap=implode("|", $map);
#---------------------------------------prev next condition
if ($prev < 0) {$prev="";}
else {$prev="<a href=\"$script?offset=$prev&keyword=$keyword\"><< PREV</a>";}
if ($total[0] > $next) {$next="<a href=\"$script?offset=$next&keyword=$keyword\">NEXT >></a>";}
else {$next="";}
?>
<html>
<head><title>CyberGL Page Scroller</title></head>
<body>
Query:
<?echo $query;?>
<hr>
<b><?echo $offset+1?> to <?echo $offset+$item_perpage?> of <?echo $total[0]?></b>
<p>
<?
#---------------------------------------query process
$data=mysql_query($query);
$no=1;
while ($result=mysql_fetch_array($data)) {
?>
NO: <?echo $no+$offset;?>. <?echo $result[name]?><p>
<? $no++;
}
#---------------------------------------page scroller
?>
<table width="100%" cellpadding=0 cellspacing=0 border=0>
<tr>
<td nowrap><?echo $prev?></td>
<td width="100%" align=center><?echo $pagemap?></td>
<td align=right nowrap><?echo $next?></td>
</tr>
</table>
</body>
</html>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Site Navigation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic. FREE! Go There Now!
|
|
|
|
Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes. FREE! Go There Now!
|
|
|
|
The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size. FREE! Go There Now!
|
|
|
|
This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML. FREE! Go There Now!
|
|
|
|
Join this webcast to see how IBM Data Studio Developer and pureQuery can take the pain out of Java data access. uApplications developed using both Java and SQL have become a common requirement. Database connectivity using Java Database Connectivity (JDBC) to create an application is a multi-step tedious process, and tooling that covers both SQL and Java has been unavailable, until now. IBM Data Studio introduces the pureQuery platform: a high-performance, Java data access platform focused on simplifying the tasks of developing, managing, and optimizing database applications and services. FREE! Go There Now!
|
|
|
|
You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online. FREE! Go There Now!
|
|
|
|
As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996. FREE! Go There Now!
|
|
|
|
Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |