Ask a Question related to Coldfusion Database Access, Design and Development.
-
cgacfox #1
How to display limited number of rows of table indatabase
I have built some CF pages to display my huge collection of DVDs and I would
like to have a limited number of rows displayed at a time. Then there would be
a forward or backward arrow so that I don't have the visitor scrolling forever
to get to the bottom of the pages. How do I do this? I can post the code that I
have now so that it will be easier to tell where the code would go. Please help
me figure this one out. Thanks.
cgacfox Guest
-
sql performance with a large number of rows in a table.
hi, I am currently using MySQL 5.0.16 on a dual pentium 4-2G system with 9G of ram. I have a number of machines that connect to the MySQL server,... -
Limited number of instert records
Hi - Using ASP/Access/Vbscript Is it possible to set a limit of for example 6 insert records of the same type in the DB? Have a product database... -
Number of WebMethods limited in .asmx file?
Hi, I'm working with a large webservice project. This project exposes many different WebMethods in the .asmx file. Recently, I've been having... -
is the number of variables limited?
hi there, anybody out there, who reached the maximal number of variables in illustrator (10)? any help appreciated. michael. -
Limited the number of decimal places returned?
I've moved on from functions for the time being, and was playing with do some maths and date/time manipulation. Lets say I wanted to show the... -
zoeski80 #2
Re: How to display limited number of rows of table indatabase
Hi cgacfox
One way to do this is to put the query into a Session variable so it will
persist from page to page.
Then when you output your first page you do a CFOUTPUT or CFLOOP using
STARTROW and ENDROW or MAXROWS to only show X items on the page. Then you make
NEXT and PREVIOUS links and pass through the value for which row to start at
for that page.
If you are showing 50 items per per the links on page 2 it will look something
like this:
NEXT - page.cfm?startRow=101
PREVIOUS - page.cfm?startRow=1
On each page you check to see if the session variable exists, if it does copy
the query from the session into a local var and use it in the loop. Otherwise
perform the query and copy into a session variable.
HTH
Zoe
zoeski80 Guest
-
cgacfox #3
Re: How to display limited number of rows of table indatabase
I am trying to post a message back and the site seems to be having a problem. This is a test.
cgacfox Guest
-
cgacfox #4
Re: How to display limited number of rows of table indatabase
I will post the code in stages:
This is the main DVD collection page:
<!--This sets up a query to be used later on in the table display-->
<!--You can use whatever name you want for the query name but no spaces-->
<!--The datasource name is the one set up in the coldfusion administrators -
the dsn-->
<!--Select * means select all-->
<!--From DVDS refers to the table name inside the database-->
<!--The Order by can be changed to any field you want in the database-->
<CFQuery Name="genre" Datasource="media">
Select genre
From genre
Order by genre
</cfquery>
<CFQuery Name="Parentalrating" Datasource="media">
Select Parentalrating
From parentalRating
Order by parentalRating
</cfquery>
<html>
<head>
<title>Media Display</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new
Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1]
: img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) { img =
document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src =
img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#5A2E10" link="#FF9900" vlink="#B4945A"
onLoad="MM_preloadImages('../Coributton_f3.gif',
'../Coributton_f2.gif','../Coributton_f4.gif','../Gregbutton_f3.gif','../Gregbut
ton_f2.gif','../Gregbutton_f4.gif',
'Ashtonbutton_f3.gif','Ashtonbutton_f2.gif','Ashto nbutton_f4.gif','Chrisbutton_f
3.gif',
'Chrisbutton_f2.gif','Chrisbutton_f4.gif','../petsbutton_f3.gif','../petsbutton_
f2.gif','../petsbutton_f4.gif',
'../Dee&Gloriabutton_f3.gif','../Dee&Gloriabutton_f2.gif','../Dee&Gl
oriabutton_f4.gif',
'../Mikebutton_f3.gif','../Mikebutton_f2.gif','../Mikebutton_f4.gif','../Mark&am
p;candybutton_f3.gif',
'../Mark&candybutton_f2.gif','../Mark&candybutton_f4.gif','thecollection
button_f3.gif',
'thecollectionbutton_f2.gif','thecollectionbutton_ f4.gif','thelibrarybutton_f3.g
if',
'thelibrarybutton_f2.gif','thelibrarybutton_f4.gif ','../guestbookbutton_f3.gif',
'../guestbookbutton_f2.gif',
'../guestbookbutton_f4.gif','../Images/contactusbutton_f2.gif','../Images/contac
tusbutton_f4.gif',
'../Images/contactusbutton_f3.gif')">
<table width="704" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="85" valign="top">
<div align="center">
<img src="Images/collectionheader.gif" alt="The Collection Header"
width="703" height="83" align="top">
</div>
</td>
</tr>
</table>
<table width="704" border="0" align="center" cellpadding="2" cellspacing="2"
summary="">
<tr>
<td width="133" height="459" valign="top" bgcolor="#5A2E10">
<a href="../home2.html" target="_top"
onClick="MM_nbGroup('down','navbar1','homebutton', '../Images/homebutton_f3.gif',
1)"
onMouseOver="MM_nbGroup('over','homebutton','../Images/homebutton_f2.gif','../Im
ages/homebutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img src="../Images/homebutton.gif" alt="Link to Home Page"
name="homebutton" width="133" height="32" border="0">
</a>
<a href="../Corispage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Coributton', '../Images/coributton_f3.gif',
1)"
onMouseOver="MM_nbGroup('over','Coributton','../Images/coributton_f2.gif','../Im
ages/coributton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img src="../Images/coributton.gif" alt="Link to Cori's Page"
name="Coributton" width="133" height="32" border="0">
</a>
<a href="../Gregspage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Gregbutton', '../Images/gregbutton_f3.gif',
1)"
onMouseOver="MM_nbGroup('over','Gregbutton','../Images/gregbutton_f2.gif','../Im
ages/gregbutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img name="Gregbutton" src="../Images/gregbutton.gif"
width="133" height="32" border="0" alt="Link to Greg's Page">
</a>
<a href="ashtonspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Ashtonbutton','../Images/ashtonbutton_f2.gif','.
../Images/ashtonbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Ashtonbutton ','../Images/ashtonbutton_f3.g
if',1)">
<img name="Ashtonbutton" src="../Images/ashtonbutton.gif"
width="133" height="32" border="0" alt="Link to Ashton's Page">
</a>
<a href="Chrispage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Chrisbutton','../Images/chrisbutton_f2.gif','../
Images/chrisbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Chrisbutton' ,'../Images/chrisbutton_f3.gif
',1)">
<img name="Chrisbutton" src="../Images/chrisbutton.gif"
width="133" height="32" border="0" alt="Link to Chris' Page">
</a>
<a href="../petspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','petsbutton','../Images/petsbutton_f2.gif','../Im
ages/petsbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','petsbutton', '../Images/petsbutton_f3.gif',
1)">
<img name="petsbutton" src="../Images/petsbutton.gif"
width="133" height="32" border="0" alt="Link to The Pets Page">
</a>
<a href="../dee&gloriaspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','DeeGloriabutton',' ../Images/dee&gloriabutton
_f2.gif','../Images/dee&gloriabutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','DeeGloriabut ton','../Images/dee&gloria
button_f3.gif',1)">
<img name="DeeGloriabutton" src="../Images/dee&gloriabutton.gif"
width="133" height="32" border="0" alt="Link to Dee & Gloria's Page">
</a>
<a href="../Mikespage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Mikebutton','../Images/mikebutton_f2.gif','../Im
ages/mikebutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Mikebutton', '../Images/mikebutton_f3.gif',
1)">
<img name="Mikebutton" src="../Images/mikebutton.gif"
width="133" height="32" border="0" alt="Link to Mike's Page">
</a>
<a href="../Mark&Candyspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Markcandybutton',' ../Images/mark&candybutton
_f2.gif','../Images/mark&candybutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Markcandybut ton','../Images/mark&candy
button_f3.gif',1)">
<img name="Markcandybutton" src="../Images/mark&candybutton.gif"
width="133" height="32" border="0" alt="Link to Mark & Candy's Page">
</a>
<img name="thecollectionbutton"
src="Images/thecollectionbutton_f5.gif" width="133" height="32" border="0"
alt="Link to The Collection Page">
<a href="TheLibrary.cfm" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','thelibrarybutton', '../Images/thelibrarybutton_f2
..gif','../Images/thelibrarybutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','thelibrarybu tton','../Images/thelibrarybut
ton_f3.gif',1)">
<img name="thelibrarybutton"
src="../Images/thelibrarybutton.gif" width="133" height="32" border="0"
alt="Link to The Library Page">
</a>
<a href="../guestbook.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','guestbookbutton',' ../Images/guestbookbutton_f2.g
if','../Images/guestbookbutton_f4.gif',1)"
onClick="MM_nbGroup('d
cgacfox Guest
-
cgacfox #5
Re: How to display limited number of rows of table indatabase
This is the code for the first filter page for Genre:
<!--This sets up a query to be used later on in the table display-->
<!--You can use whatever name you want for the query name but no spaces-->
<!--The datasource name is the one set up in the coldfusion administrators -
the dsn-->
<!--Select * means select all-->
<!--From DVDS refers to the table name inside the database-->
<!--The Order by can be changed to any field you want in the database-->
<CFQuery Name="DisplayGenre" Datasource="DVDS">
Select *
From DVDS
WHERE genre LIKE '%#FORM.genre#%'
Order by MovieTitle
</cfquery>
<CFQuery Name="filtergenre" Datasource="dvds">
Select genre
From genre
Order by genre
</cfquery>
<CFQuery Name="filterparentalRating" Datasource="dvds">
Select parentalRating
From parentalRating
Order by parentalRating
</cfquery>
<CFSET RowsPerPage = 10>
<CFPARAM name="URL.StartRow" default="1" type="numeric">
<cfset TotalRows = DisplayGenre.RecordCount>
<cfset EndRow = Min(URL.StartRow + RowsPerPage - 1, TotalRows)>
<cfset StartRowNext = EndRow + 1>
<cfset StartRowBack = URL.StartRow - RowsPerPage>
<html>
<head>
<title>Media Display</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new
Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1]
: img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) { img =
document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src =
img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<style type="text/css">
<!--
.style1 {font-family: Geneva, Arial, Helvetica, sans-serif}
.style2 {
color: #FFFFFF;
font-weight: bold;
}
.style3 {color: #FFFFFF}
.style4 {color: #FFFFFF; font-family: Geneva, Arial, Helvetica, sans-serif; }
-->
</style>
</head>
<body bgcolor="#5A2E10" link="#CC6600"
vlink="#FF9900"onLoad="MM_preloadImages('images/coributton_f3.gif','images/corib
utton_f2.gif','images/coributton_f4.gif','images/gregbutton_f3.gif','images/greg
button_f2.gif','images/gregbutton_f4.gif','Securitypages/images/ashtonbutton_f3.
gif','Securitypages/images/ashtonbutton_f2.gif','Securitypages/images/ashtonbutt
on_f4.gif','Securitypages/images/chrisbutton_f3.gif','Securitypages/images/chris
button_f2.gif','Securitypages/images/chrisbutton_f4.gif','images/petsbutton_f3.g
if','images/petsbutton_f2.gif','images/petsbutton_f4.gif','images/dee&gloria
button_f3.gif','images/dee&gloriabutton_f2.gif','images/dee&gloriabutton
_f4.gif','images/mikebutton_f3.gif','images/mikebutton_f2.gif','images/mikebutto
n_f4.gif','images/mark&candybutton_f3.gif','images/mark&candybutton_f2.g
if','images/mark&candybutton_f4.gif','Securitypages/images/thelibrarybutton_
f3.gif','Securitypages/images/thelibrarybutton_f2.gif','Securitypages/images/the
librarybutton_f4.gif','images/guestbookbutton_f3.gif','images/guestbookbutton_f2
..gif','images/guestbookbutton_f4.gif')">
<table width="704" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="85" valign="top">
<div align="center">
<img src="Images/collectionheader.gif" alt="foxdenheader" width="703"
height="83" align="top">
</div>
</td>
</tr>
</table>
<table width="704" border="0" align="center" cellpadding="2" cellspacing="2"
summary="">
<tr>
<td width="133" height="459" valign="top" bgcolor="#5A2E10">
<a href="../home2.html" target="_top"
onClick="MM_nbGroup('down','navbar1','homebutton', 'images/homebutton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','homebutton','image s/homebutton_f2.gif','images/h
omebutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img name="homebutton" src="../images/homebutton.gif" width="133"
height="32" border="0" alt="Link to Home Page">
</a>
<a href="../Corispage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Coributton', 'images/coributton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','Coributton','image s/coributton_f2.gif','images/c
oributton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img src="../images/coributton.gif" alt="Link to Cori's Page"
name="Coributton" width="133" height="32" border="0">
</a>
<a href="../Gregspage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Gregbutton', 'images/gregbutton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','Gregbutton','image s/gregbutton_f2.gif','images/g
regbutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img name="Gregbutton" src="../images/gregbutton.gif"
width="133" height="32" border="0" alt="Link to Greg's Page">
</a>
<a href="ashtonspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Ashtonbutton','Sec uritypages/images/ashtonbutton
_f2.gif','Securitypages/images/ashtonbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Ashtonbutton ','Securitypages/images/ashton
button_f3.gif',1)">
<img name="Ashtonbutton" src="../Images/ashtonbutton.gif"
width="133" height="32" border="0" alt="Link to Ashton's Page">
</a>
<a href="chrispage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Chrisbutton','Secu ritypages/images/chrisbutton_f
2.gif','Securitypages/images/chrisbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Chrisbutton' ,'Securitypages/images/chrisbu
tton_f3.gif',1)">
<img name="Chrisbutton" src="../Images/chrisbutton.gif"
width="133" height="32" border="0" alt="Link to Ashton's Page"> </a>
<a href="../petspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','petsbutton','image s/petsbutton_f2.gif','images/p
etsbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','petsbutton', 'images/petsbutton_f3.gif',1)"<img name="petsbutton" src="../images/petsbutton.gif">
width="133" height="32" border="0" alt="Link to The Pets Page">
</a>
<a href="../Dee&gloriaspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','DeeGloriabutton',' images/dee&gloriabutton_f2
..gif','images/dee&gloriabutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','DeeGloriabut ton','images/dee&gloriabut
ton_f3.gif',1)">
<img name="DeeGloriabutton" src="../images/dee&gloriabutton.gif"
width="133" height="32" border="0" alt="Link to Dee & Gloria's Page"> </a>
<a href="../Mikespage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Mikebutton','image s/mikebutton_f2.gif','images/m
ikebutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Mikebutton', 'images/mikebutton_f3.gif',1)"<img name="Mikebutton" src="../images/mikebutton.gif">
width="133" height="32" border="0" alt="Link to Mike's Page">
</a>
<a href="../mark&candyspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Markcandybutton',' images/mark&candybutton_f2
..gif','images/mark&candybutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Markcandybut ton','images/mark&candybut
ton_f3.gif',1)">
<img name="Markcandybutton" src="../images/mark&candybutton.gif"
width="133" height="32" border="0" alt="Link to Mark & Candy's Page">
</a>
<img name="thecollectionbutton"
src="images/thecollectionbutton_f5.gif" width="133" height="32" border="0"
alt="Link to The Collection Page">
<a href="thelibrary.cfm" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over'
cgacfox Guest
-
cgacfox #6
Re: How to display limited number of rows of table indatabase
This is the code for the back/next page from the book:
<!--
Filename: NextNIncludeBackNext.cfm
Created by: Nate Weiss (NMW)
Purpose: Displays Back and Next links for record navigation
Please Note Included by the NextN.cfm template in this folder
-->
<!--Provide Next/Back links-->
<cfoutput>
<!--Show link for Back, if appropriate-->
<cfif StartRowBack GT 0>
<A href="#CGI.SCRIPT_NAME#?StartRow=#StartRowBack#">
<img SRC"../Images/BrowseBack.gif" width="40" height="16"
alt="Back #RowsPerPage# Records" border="0"
</A>
</cfif>
<!--Show link for Next, if appropriate-->
<cfif StartRowNext LTE TotalRows>
<a href="#CGI.SCRIPT_NAME#?StartRow=#StartRowNext#">
<img src="../Images/BrowseNext.gif" width="40" height="16"
alt="Next #RowsPerPage# Records" Border="0"
</a>
</cfif>
</cfoutput>
cgacfox Guest
-
cgacfox #7
Re: How to display limited number of rows of table indatabase
I am so sorry about the formatting. It seems that the site doesn't maintain the
formatting of the code as I have it in Dreamweaver MX 2004. I like clean code
that one doesn't have to scroll all the way to the right for. Again, I
apologize.
cgacfox Guest
-
trendline #8
Re: How to display limited number of rows of table indatabase
I use this on my site: <cfset rowsPerPage = 10> <cfset totalRows =
yourQuery.recordCount> <cfset endRow = Min(url.startRow + rowsPerPage - 1,
totalRows)> <cfset startRowNext = endRow + 1> <cfset startRowBack =
url.startRow - rowsPerPage> And then for Next/Back links:
<!--- Show link for Back, if appropriate --->
<cfif startRowBack GT 0>
<font face="Webdings">3</font>
<a
href="#CGI.SCRIPT_NAME#?startRow=#startRowBack"><s trong>Back</strong></a>
</cfif>
<!--- Show link for Next, if appropriate --->
<cfif startRowNext LTE TotalRows>
<a
href="#CGI.SCRIPT_NAME#?startRow=#startRowNext"><s trong>Next</strong></a>
<font face="Webdings">4</font>
</cfif>
trendline Guest
-
cgacfox #9
Re: How to display limited number of rows of table indatabase
Thanks trendline. This is almost exactly what I have from my book. I do notice
there are some things that are different, however. I will give this a try and
see what happens. I suppose that I have to put this code on each .cfm page that
will produce database records, i.e. genre.cfm, parentalrating.cfm, etc. and I
don't think I have to put it on the main page because it doesn't call up any of
the records from the database. Did you look at my code? Maybe I have this code
written in the incorrect sections of the overall code.
cgacfox Guest
-
cgacfox #10
Re: How to display limited number of rows of table indatabase
I have tweaked the code to work on my site. However, there seems to be a
problem with the number of records showing. Case in point is I choose to pull
up all the comedy dvds and there should be 41 records. The page is showing all
41 and they are repeating about 3 to 4 times. It is not showing just the first
ten. When I hit the forward button, I get this error: Error Occurred While
Processing Request Element GENRE is undefined in FORM. The Error
Occurred in C:\CFusionMX\wwwroot\DVDNextN\Genre.cfm: line 11 9 : Select * 10
: From DVDS 11 : WHERE genre LIKE '%#FORM.genre#%' 12 : Order by MovieTitle 13
: </cfquery> Someone needs to go through my code and see why this is
happening. I wrote the code over a year ago with the help of my Web Programming
instructor in college. She set up most of the code for filtering and such.
<!--This sets up a query to be used later on in the table display-->
<!--You can use whatever name you want for the query name but no spaces-->
<!--The datasource name is the one set up in the coldfusion administrators -
the dsn-->
<!--Select * means select all-->
<!--From DVDS refers to the table name inside the database-->
<!--The Order by can be changed to any field you want in the database-->
<CFQuery Name="displayGenre" Datasource="#request.datasource#">
Select *
From DVDS
WHERE genre LIKE '%#FORM.genre#%'
Order by MovieTitle
</cfquery>
<CFQuery Name="filtergenre" Datasource="#request.datasource#">
Select genre
From genre
Order by genre
</cfquery>
<CFQuery Name="filterparentalRating" Datasource="#request.datasource#">
Select parentalRating
From parentalRating
Order by parentalRating
</cfquery>
<cfset rowsPerPage = 10>
<cfparam name="url.startRow" default="1" type="numeric">
<cfset totalRows = displayGenre.recordCount>
<cfset endRow = Min(url.startRow + rowsPerPage - 1, totalRows)>
<cfset startRowNext = endRow + 1>
<cfset startRowBack = url.startRow - rowsPerPage>
<html>
<head>
<title>Media Display</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new
Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1]
: img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) { img =
document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src =
img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) !=
null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<style type="text/css">
<!--
.style1 {font-family: Geneva, Arial, Helvetica, sans-serif}
.style2 {
color: #FFFFFF;
font-weight: bold;
}
.style3 {color: #FFFFFF}
.style4 {color: #FFFFFF; font-family: Geneva, Arial, Helvetica, sans-serif; }
-->
</style>
</head>
<body bgcolor="#5A2E10" link="#CC6600"
vlink="#FF9900"onLoad="MM_preloadImages('images/coributton_f3.gif','images/corib
utton_f2.gif','images/coributton_f4.gif','images/gregbutton_f3.gif','images/greg
button_f2.gif','images/gregbutton_f4.gif','Securitypages/images/ashtonbutton_f3.
gif','Securitypages/images/ashtonbutton_f2.gif','Securitypages/images/ashtonbutt
on_f4.gif','Securitypages/images/chrisbutton_f3.gif','Securitypages/images/chris
button_f2.gif','Securitypages/images/chrisbutton_f4.gif','images/petsbutton_f3.g
if','images/petsbutton_f2.gif','images/petsbutton_f4.gif','images/dee&gloria
button_f3.gif','images/dee&gloriabutton_f2.gif','images/dee&gloriabutton
_f4.gif','images/mikebutton_f3.gif','images/mikebutton_f2.gif','images/mikebutto
n_f4.gif','images/mark&candybutton_f3.gif','images/mark&candybutton_f2.g
if','images/mark&candybutton_f4.gif','Securitypages/images/thelibrarybutton_
f3.gif','Securitypages/images/thelibrarybutton_f2.gif','Securitypages/images/the
librarybutton_f4.gif','images/guestbookbutton_f3.gif','images/guestbookbutton_f2
..gif','images/guestbookbutton_f4.gif')">
<table width="704" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="85" valign="top">
<div align="center">
<img src="Images/collectionheader.gif" alt="foxdenheader" width="703"
height="83" align="top">
</div>
</td>
</tr>
</table>
<table width="704" border="0" align="center" cellpadding="2" cellspacing="2"
summary="">
<tr>
<td width="133" height="459" valign="top" bgcolor="#5A2E10">
<a href="../home2.html" target="_top"
onClick="MM_nbGroup('down','navbar1','homebutton', 'images/homebutton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','homebutton','image s/homebutton_f2.gif','images/h
omebutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img name="homebutton" src="../images/homebutton.gif" width="133"
height="32" border="0" alt="Link to Home Page">
</a>
<a href="../Corispage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Coributton', 'images/coributton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','Coributton','image s/coributton_f2.gif','images/c
oributton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img src="../images/coributton.gif" alt="Link to Cori's Page"
name="Coributton" width="133" height="32" border="0">
</a>
<a href="../Gregspage.html" target="_top"
onClick="MM_nbGroup('down','navbar1','Gregbutton', 'images/gregbutton_f3.gif',1)"
onMouseOver="MM_nbGroup('over','Gregbutton','image s/gregbutton_f2.gif','images/g
regbutton_f4.gif',1)"
onMouseOut="MM_nbGroup('out');">
<img name="Gregbutton" src="../images/gregbutton.gif"
width="133" height="32" border="0" alt="Link to Greg's Page">
</a>
<a href="ashtonspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Ashtonbutton','Sec uritypages/images/ashtonbutton
_f2.gif','Securitypages/images/ashtonbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Ashtonbutton ','Securitypages/images/ashton
button_f3.gif',1)">
<img name="Ashtonbutton" src="../Images/ashtonbutton.gif"
width="133" height="32" border="0" alt="Link to Ashton's Page">
</a>
<a href="chrispage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Chrisbutton','Secu ritypages/images/chrisbutton_f
2.gif','Securitypages/images/chrisbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Chrisbutton' ,'Securitypages/images/chrisbu
tton_f3.gif',1)">
<img name="Chrisbutton" src="../Images/chrisbutton.gif"
width="133" height="32" border="0" alt="Link to Ashton's Page"> </a>
<a href="../petspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','petsbutton','image s/petsbutton_f2.gif','images/p
etsbutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','petsbutton', 'images/petsbutton_f3.gif',1)"<img name="petsbutton" src="../images/petsbutton.gif">
width="133" height="32" border="0" alt="Link to The Pets Page">
</a>
<a href="../Dee&gloriaspage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','DeeGloriabutton',' images/dee&gloriabutton_f2
..gif','images/dee&gloriabutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','DeeGloriabut ton','images/dee&gloriabut
ton_f3.gif',1)">
<img name="DeeGloriabutton" src="../images/dee&gloriabutton.gif"
width="133" height="32" border="0" alt="Link to Dee & Gloria's Page"> </a>
<a href="../Mikespage.html" target="_self"
onMouseOut="MM_nbGroup('out');"
onMouseOver="MM_nbGroup('over','Mikebutton','image s/mikebutton_f2.gif','images/m
ikebutton_f4.gif',1)"
onClick="MM_nbGroup('down','navbar1','Mikebutton', 'images/mikebutton_f3.gif',1)"<img name="Mikebutton" src="../images/mikebutton.gif">
width="133" height="32" border="0" alt="Link to Mike
cgacfox Guest
-
cf_menace #11
Re: How to display limited number of rows of table indatabase
The problem is your query is expecting the variable "genre" to be in the FORM
scope. Meaning, it's expecting "genre" to be POSTed by a form to the current
page.
What you'll need to do is alter your code to something like this:
<cfparam name="request.genre" type="string" default="">
<cfif IsDefined("form.genre")>
<cfset request.genre = form.genre>
</cfif>
<cfif IsDefined("url.genre")>
<cfset request.genre = url.genre>
</cfif>
<CFQuery Name="displayGenre" Datasource="#request.datasource#">
Select *
From DVDS
WHERE genre LIKE '%#request.genre#%'
Order by MovieTitle
</cfquery>
<!--- yadda yadda yadda --->
<a href="somepage.cfm?startRow=#nextRow#&genre=#reque st.genre#">Next ></a>
cf_menace Guest
-
cgacfox #12
Re: How to display limited number of rows of table indatabase
cf_menace: I have attempted to try your suggestion and it keeps getting uglier
by the minute. Could I attach my original code before I started doing anything
to it at all and see if you can insert the proper code where it should belong?
If this doesn't work, then I will leave the pages alone and my visitors can
deal with it!
cgacfox Guest
-
cgacfox #13
Re: How to display limited number of rows of table indatabase
This is the original code for a bookgenre.cfm page. I don't have an untouched
copy of the dvd genre page. It is the same code except for my book collection
instead of my dvd collection. I thought that it would be nice to have the
ability to only display 10 pages at a time so that the visitor was not
scrolling so much for larger record numbers. The more I play with the dvd genre
page, the worse it is becoming.
<!--This sets up a query to be used later on in the table display-->
<!--You can use whatever name you want for the query name but no spaces-->
<!--The datasource name is the one set up in the coldfusion administrators -
the dsn-->
<!--Select * means select all-->
<!--From DVDS refers to the table name inside the database-->
<!--The Order by can be changed to any field you want in the database-->
<CFQuery Name="DisplaybookGenre" Datasource="media">
Select *
From Books
WHERE bookgenre LIKE '%#FORM.bookgenre#%'
Order by BookTitle
</cfquery>
<CFQuery Name="filtergenre" Datasource="media">
Select bookgenre
From bookgenre
Order by bookgenre
</cfquery>
<html>
<head>
<title>Book Display</title>
<!--This JavaScript was written by Kilton Hopkins. It's purpose is to cause
the menu buttons to appear to go down and back up when clicked.-->
<script>
function changeButton(ID, newButton)
{
var img = document.getElementById(ID);
img.src = newButton;
}
</script>
<!--This is an example of embedded style. I didn't want to use the main
CSS for a few pages but I wanted some things included in all pages so I
used embedded CSS-->
<style>
a:link {
font-weight: bold;
color: #000000;
}
a:visited {
font-weight: bold;
color: #990000;
}
a:active {
font-weight: bold;
color: #FF0033;
}
a:hover {
font-weight: bold;
color: #FFFF00;
}
</style>
</head>
<body background="images/owl&books2.gif">
<h1><Div align="center">Book Genre Results</div></font></h1>
<form method="POST" action="bookGenre.cfm">
Select Book Genre:<br>
<Select Name="bookGenre">
<Option value="">Filter by bookGenre</option>
<cfoutput query="filtergenre">
<option value="#bookgenre#">#bookgenre#</option>
</cfoutput>
</select>
<input type="submit" value="Go">
</FORM>
<form method="Post" action="booktitle.cfm">
Enter name of the book that you are interested in seeing.<br>
<input type="text" name="booktitle" size="50">
<input type="submit" value="Go"><br>
</form>
<form method="Post" action="author.cfm">
Enter name of the author that you are interested in seeing.<br>
<input type="text" name="authors" size="50">
<input type="submit" value="Go"><br>
</form>
<form method="Post" action="publisher.cfm">
Enter name of the publisher that you are interested in seeing.<br>
<input type="text" name="publisher" size="50">
<input type="submit" value="Go"><br>
</form>
<form method="Post" action="displayallbooks.cfm">
If you would like to see all titles please click here. <input type="submit"
value="Go"><br><font size="5"> WARNING: Due to the size of the
database, this could take some time to download.</font><br>
</form>
</font>
<table border="0" width="100%" cellspacing="0">
<tr>
<td width="20%">
<strong>Book Title</strong>
</td>
<td width="20%">
<strong>Book Genre</strong>
</td>
<td width="40%">
<strong>Author</strong>
</td>
</tr>
<!--Here is where the cfoutput begins-->
<!--The query name defined above is used-->
<cfoutput query ="DisplaybookGenre">
<!--An if statement that tests to see if the row is odd or even-->
<!--if the row is odd a variable called bgcolor is set to silver-->
<!--if the row is even the variable bgcolor is set to white-->
<cfif currentrow mod 2 is 1>
<cfset bgcolor="feldspar">
<cfelse>
<cfset bgcolor="lightsalmon">
</cfif>
<!--the variable defined above is used to set the row color-->
<tr bgcolor="#bgcolor#">
<!--4 different fields from the database are displayed-->
<!--since we said to include all records there will be 284 rows in the
database - one for each record in the table-->
<td width="20%">
<a href="bookDetail.cfm?booktitle=#Displaybookgenre.b ooktitle#">
#bookTitle#
</a>
</td>
<td width="20%">
#bookgenre#
</td>
<td width="40%">
#Author#
</td>
</tr>
</cfoutput>
<!--Here is where the cfoutput ends-->
</table>
<p>
<div align="center">
<a href="../index.html">
<img border="0" id="Button1" src="../homebutton1.gif " alt="Link to Home Page"
height="30" width="100"
onmousedown="changeButton('Button1', '../homebutton2.gif');"
onmouseup="changeButton('Button1', '../homebutton1.gif');"></a>
<a href="../Corispage.html">
<img border="0" id="Button2" src="../coributton1.gif" alt="Link to Cori's
Page" height="30" width="100"
onmousedown="changeButton('Button2', '../coributton2.gif');"
onmouseup="changeButton('Button2', '../coributton1.gif');"></a>
<a href="../Gregspage.html">
<img border="0" id="Button3" src="../gregbutton1.gif" alt="Link to Greg's
Page" height="30" width="100"
onmousedown="changeButton('Button3', '../gregbutton2.gif');"
onmouseup="changeButton('Button3', '../gregbutton1.gif');"></a>
<a href="Ashtonspage.html">
<img border="0" id="Button4" src="../ashtonbutton1.gif"
onmousedown="changeButton('Button4', '../ashtonbutton2.gif');"
onmouseup="changeButton('Button4', '../ashtonbutton1.gif');"></a>
<a href="Chrispage.html">
<img border="0" id="Button5" src="../chrisbutton1.gif" alt="Link to Chris'
Page" height="30" width="100"
onmousedown="changeButton('Button5', '../chrisbutton2.gif');"
onmouseup="changeButton('Button5', '../chrisbutton1.gif');"></a>
<a href="../petframecontrol.html">
<img border="0" id="Button6" src="../thepetsbutton1.gif" alt="Link to The Pets
Page" height="30" width="100"
onmousedown="changeButton('Button6', '../thepetsbutton2.gif');"
onmouseup="changeButton('Button6', '../thepetsbutton1.gif');"></a>
<a href="../Dee&Gloriaspage.html">
<img border="0" id="Button7" src="../deegloriabutton1.gif" alt="Link to Dee &
Gloria's Page" height="30" width="100"
onmousedown="changeButton('Button7', '../deegloriabutton2.gif');"
onmouseup="changeButton('Button7', '../deegloriabutton1.gif');"></a>
<a href="../Mark&Candyspage.html">
<img border="0" id="Button8" src="../markcandybutton1.gif" alt="Link to Mark &
Candy's Page" height="30" width="100"
onmousedown="changeButton('Button8', '../markcandybutton2.gif');"
onmouseup="changeButton('Button8', '../markcandybutton1.gif');"></a>
<a href="../mikespage.html">
<img border="0" id="Button12" src="../mikebutton1.gif" alt="Link to Mike's
Page" height="30" width="100"
onmousedown="changeButton('Button12', '../mikebutton2.gif');"
onmouseup="changeButton('Button12', '../mikebutton1.gif');"></a>
<a href="mailto:cgacfox@comcast.net">
<img border="0" id="Button10" src="../contactusbutton1.gif" alt="Link to
Email" height="30" width="100"
onmousedown="changeButton('Button10', '../contactusbutton2.gif');"
onmouseup="changeButton('Button10', '../contactusbutton1.gif');"></a>
<a href="../guestbook.html"><img border="0" id="Button11"
src="../guestbookbutton1.gif" alt="Link to Guestbook Page" height="30"
width="100"
onmousedown="changeButton('Button11', '../guestbookbutton2.gif');"
onmouseup="changeButton('Button11', '../guestbookbutton1.gif');"></a>
</div>
</p>
<p><div align="center"><font size=-2 face="arial">Copyright © 2004 Cori
Foxworthy. All rights reserved.</font></div><br>
<p><div align="center"><font size=-2 face="arial">Last updated
05/05/2004.</font></div><br>
</body>
</html>
cgacfox Guest



Reply With Quote

