Cold Fusion Display FAQ

Reply

Join Date: Mar 2009
Posts: 1
Reputation: evilsanta03 is an unknown quantity at this point 
Solved Threads: 0
evilsanta03 evilsanta03 is offline Offline
Newbie Poster

Cold Fusion Display FAQ

 
0
  #1
19 Days Ago
Hi All,

I am new to this Coldfusion and i am creating a FAQ page.
My Database is MS ACCESS. It is working but with some code error as i am displaying 5 FAQ on first page then next 5 FAQ on the other page and so on. The PROBLEM i am having is lets say my Database has 18 faqs.
it would display
page 1 --- 5 FAQ
page 2 --- 5 FAQ
page 3 --- 5 FAQ
PAGE 4 --- DOESNT SHOW ANY FAQ so the remaining 3 are not retrieved from the database.

I will be very thankful if you guys can please help me with this issue.

Below is the code :
*****************************************************

  1. <html>
  2. <head>
  3. <title>Frequently Asked Questions</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <link href="FAQStylesheet.css" rel="stylesheet" type="text/css">
  6.  
  7. </head>
  8.  
  9. <body>
  10. <img src="RMA.JPG" width="960" height="63">
  11. <hr><hr>
  12. <H2>FREQUENTLY ASKED QUESTIONS</H2>
  13. <hr>
  14. <br>
  15. <form action="search.cfm" method="post">
  16. <input type="submit" name="Search" value="Search FAQ">
  17. </form>
  18. <br><br><br>
  19.  
  20. <cfquery name="getfaq" datasource="faqdatabase">
  21. Select *
  22. from qa
  23. order by qarefno desc
  24. </cfquery>
  25.  
  26. <cfparam name="URL.PageIndex" default="0">
  27. <cfset Recordsperpage=5 >
  28. <cfset totalpages=(getfaq.recordcount/recordsperpage)-1>
  29. <cfset startrow=(URL.pageindex*recordsperpage)+1>
  30. <cfset endrow=(startrow+recordsperpage)-1>
  31.  
  32. <cfoutput>
  33. <cfloop query="getfaq" >
  34. <cfif currentrow gte startrow>
  35.  
  36. <Strong>Qusetion#getfaq.qarefno# :
  37. #getfaq.fquestion#</Strong><br>
  38. <Strong>Answer:</Strong> <h4>#getfaq.fanswer#</h4>
  39.  
  40.  
  41. <br><br><br><br><br>
  42. </cfif>
  43. <cfif currentrow eq endrow>
  44. <cfbreak>
  45. </cfif>
  46. </cfloop>
  47. </cfoutput>
  48. <strong>
  49. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  50. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  51. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  52. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  53. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  54. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  55. Select Page</strong>
  56. <cfloop index="pages" from="0" to="#totalpages#">
  57. <cfoutput>
  58. |
  59. <cfset displaypgno=pages+1>
  60. <cfif URL.pageindex eq pages>
  61. <strong>#displaypgno#</strong>
  62.  
  63. <cfelse>
  64. <a href="?pageindex=#pages#">#displaypgno#</a>
  65. </cfif>
  66. |
  67. </cfoutput>
  68. </cfloop>
  69.  
  70.  
  71.  
  72. </body>
  73. </html>

*****************************************************

Pls help!
Last edited by peter_budo; 17 Days Ago at 6:39 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 337
Reputation: freshfitz is an unknown quantity at this point 
Solved Threads: 27
freshfitz freshfitz is offline Offline
Posting Whiz
 
0
  #2
2 Days Ago
Hope this helps

  1. <html>
  2.  
  3. <head>
  4. <title>Frequently Asked Questions</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="FAQStylesheet.css" rel="stylesheet" type="text/css">
  7.  
  8. </head>
  9.  
  10. <body>
  11. <img src="RMA.JPG" width="960" height="63">
  12. <hr><hr>
  13. <H2>FREQUENTLY ASKED QUESTIONS</H2>
  14. <hr>
  15. <br>
  16. <form action="search.cfm" method="post">
  17. <input type="submit" name="Search" value="Search FAQ">
  18. </form>
  19. <br><br><br>
  20. <cfquery name="getfaq" datasource="#application.dsn#">
  21. Select *
  22. from games
  23. order by game desc
  24. </cfquery>
  25.  
  26. <cfparam name="URL.PageIndex" default="0">
  27.  
  28. <cfif IsDefined("Getfaq.RecordCount")>
  29. <cfif NOT IsDefined("FORM.CurrentPage")>
  30. <cfset variables.CurrentPage = 1>
  31. <cfelse>
  32. <cfset variables.CurrentPage = FORM.CurrentPage>
  33. </cfif>
  34. <!--- Calculate the total number of pages. --->
  35. <cfscript>
  36. variables.ItemsPerPage = 5;
  37. if (Getfaq.RecordCount LT variables.ItemsPerPage)
  38. variables.TotalPages = 1;
  39. else
  40. variables.TotalPages = NumberFormat(GetFaq.RecordCount / variables.ItemsPerPage, 9999);
  41. </cfscript>
  42. <!--- Since the rounding up doesn't work, if there are items left over for an extra page, add it here. --->
  43. <cfif Getfaq.RecordCount - (variables.TotalPages * 100) GT 0>
  44. <cfset variables.TotalPages = variables.TotalPages + 1>
  45. </cfif>
  46. <!--- Check to make sure the user doesn't try to go beyond the Total number of pages. --->
  47. <cfif variables.CurrentPage GT variables.TotalPages>
  48. <cfset variables.CurrentPage = variables.TotalPages>
  49. </cfif>
  50. <!--- Calculate the Start and End points for the Items Query. --->
  51. <cfscript>
  52. variables.Start = (variables.CurrentPage * variables.ItemsPerPage) - 4;
  53. variables.End = (variables.CurrentPage * variables.ItemsPerPage);
  54. </cfscript>
  55. </cfif>
  56.  
  57. <cfif IsDefined("Getfaq.RecordCount")>
  58. <script language="JavaScript">
  59. function validateform_gotobreadcrumb (f) {
  60. if (f.CurrentPage.value == "") {
  61. alert("Please enter a page number before clicking the GO button.");
  62. return false;
  63. }
  64. return true;
  65. }
  66. function GoToPageN() {
  67. if (validateform_gotobreadcrumb(document.viewPage)) document.viewPage.submit();
  68. }
  69.  
  70. function SortList(sortorder) {
  71. document.viewPage.SortOrder.value = sortorder;
  72. document.viewPage.CurrentPage.value = 1;
  73. if (validateform_gotobreadcrumb(document.viewPage)) document.viewPage.submit();
  74. }
  75.  
  76. </script>
  77. <cfif variables.TotalPages GT 1>
  78. <strong><cfoutput>#Getfaq.RecordCount#</cfoutput> total items found.</strong><br><br>
  79. <form action="test.cfm" method="post" name="viewPage">
  80. View Page: <select name="CurrentPage"><cfloop from="1" to="#variables.TotalPages#" index="i"><cfoutput><option value="#i#"<cfif variables.CurrentPage IS i> selected</cfif>>#i#</option></cfoutput></cfloop></select> <strong>of <cfoutput>#variables.TotalPages#</cfoutput></strong>&nbsp;&nbsp; <input type="Button" value="Go" onclick="GoToPageN();">
  81. </form>
  82. </cfif>
  83. </cfif>
  84.  
  85.  
  86.  
  87. <cfoutput>
  88.  
  89. <cfloop query="getfaq" startrow="#variables.Start#" endrow="#variables.End#">
  90.  
  91.  
  92. <Strong>Qusetion#getfaq.game# :
  93.  
  94. #getfaq.week#</Strong><br>
  95.  
  96. <Strong>Answer:</Strong> <h4>#getfaq.home_team#</h4>
  97.  
  98.  
  99.  
  100.  
  101.  
  102. <br><br><br><br><br>
  103.  
  104.  
  105.  
  106. <cfif start eq end>
  107.  
  108. <cfbreak>
  109.  
  110. </cfif>
  111.  
  112. </cfloop>
  113.  
  114. </cfoutput>
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. </body>
Last edited by freshfitz; 2 Days Ago at 12:49 am.
Reply With Quote Quick reply to this message  
Reply

Tags
coldfusion, dreamweaver

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC