8 Replies Latest reply on Jul 20, 2006 8:45 AM by ClayD

    Returning Records, Some Need To Be Detail Pages

    ClayD Level 1
      Hello,

      I have a basic cfoutput query that will created a list of all departments and phone numbers in my directory. However, some of the records will need to go to a detail page where numbers of employees in that department are listed. I think have a decent idea how to do this, but I'm not 100% on it. Would anyone be willing to shed some light on this for me?

        • 1. Re: Returning Records, Some Need To Be Detail Pages
          Dan Bracuk Level 5
          in your resuts page, ensure your query selects a department id field. Then, when outputting your display, include an anchor tag that includes the department id as as url variable.

          Use this url variable in a query on your details page.
          • 2. Re: Returning Records, Some Need To Be Detail Pages
            ClayD Level 1
            Here's my query. I don't fully understand what you are talking about doing. The employee data is in another table and the detail pages would only be required if the department name in another table matched the rsDeptLis.Depart_Nam.


            <cfoutput query="rsDeptList">
            <table width="100%" cellspacing="0" cellpadding="0">
            <tr>
            <td>#rsDeptList.Department_Name#</td>
            <td>#rsDeptList.Phone_Number#</td>
            </tr>
            </table>
            </cfoutput>
            • 3. Re: Returning Records, Some Need To Be Detail Pages
              paross1 Level 2
              That isn't a query, just the output of a query. You would probably want your "first" query to select some sort of ID field that you could pass to your action page, where you would use it to select your "detail" using a second query and display it there.

              Phil
              • 4. Re: Returning Records, Some Need To Be Detail Pages
                Dan Bracuk Level 5
                this
                <td>#rsDeptList.Department_Name#</td>
                becomes somthing like
                <td><a href="details.cfm?id=#department_id#">#rsDeptList.Department_Name#</a></td>

                • 5. Re: Returning Records, Some Need To Be Detail Pages
                  ClayD Level 1
                  I know how to make it go to a detail page. What I'm asking is how do I make the link to do the detail page only if the department name in another table is the same as the one being displayed. If there isn't employees under that department I don't want it listed.
                  • 6. Re: Returning Records, Some Need To Be Detail Pages
                    ClayD Level 1
                    Let me explain again, there are two tables. 1) Has the Department Name and Phone Number. There isn't really any id's because of the way it was orginally set up. Now there's a table in our directory that has user's departments. What I want to do is create a listing for Departments, which I have done with the code below. HOwever, what I need to do is add a detail page link where users exist in that department. If they don't exist...I don't need there to be a link. Make Sense?

                    The field in the other table is called department_name as well. Here's the code:

                    <cfquery name="rsDeptList" datasource="empdirectory" username="sa" password="madmind">
                    SELECT *
                    FROM dbo.Departments
                    ORDER BY Department_Name ASC
                    </cfquery>


                    <cfquery name="rsDepartmentList" datasource="empdirectory" username="sa" password="madmind">
                    SELECT department_name
                    FROM dbo.dep_personel
                    ORDER BY department_name ASC
                    </cfquery>


                    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
                    <html>
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                    <title>Untitled Document</title>
                    </head>

                    <body>
                    <table width="780" cellspacing="0" cellpadding="0">
                    <tr>
                    <td><cfoutput query="rsDeptList">
                    <table width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                    <td><a href="department_details.cfm?department_name=#department_name#">#rsDeptList.Department_Na me#</a></td>
                    <td>#rsDeptList.Phone_Number#</td>
                    </tr>
                    </table>
                    </cfoutput></td>
                    </tr>
                    </table>
                    </body>
                    </html>
                    • 7. Re: Returning Records, Some Need To Be Detail Pages
                      Dan Bracuk Level 5
                      Then use the department name instead of the id as your url variable. Plus, since you are sending text instead of a number, I recommend using the urlencodedformat function,
                      • 8. Re: Returning Records, Some Need To Be Detail Pages
                        ClayD Level 1
                        Here's the thing though, some won't have detailed pages to go to. How do I create the app so the link only shows up for those who have members for their department?