This is enhancement of Page Scroller, I add a total records amount and NEXT PREV condition so the PREV link wont show in the first page and NEXT link wont show in the last 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: scroller2.php3,v 0.2 2001/06/4 15:29:53 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="scroller2.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
#---------------------------------------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?> 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><?echo $prev?></td>
<td align=right><?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! |
Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
|
|
|
|
Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right." FREE! Go There Now!
|
|
|
|
Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
|
|
|
|
WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects. FREE! Go There Now!
|
|
|
|
Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today. FREE! Go There Now!
|
|
|
|
This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today! FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered! FREE! Go There Now!
|
|
|
|
Because access to government information continues to be an area of concern for many U.S. citizens with disabilities, the U.S. government enacted Section 508 of the Rehabilitation Act in 2001 to ensure that government agencies create accessible Web content, enabling all citizens to access the information they need. A fully accessible Web site makes Web content accessible to all individuals, including those with disabilities, who may be accessing Web content via a variety of user agents. Common user agents include standard Web browsers, text-only browsers, assistive devices and mobile devices such as cell phones or personal digital assistants (PDAs). FREE! Go There Now!
|
|
|
|
As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |