• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Returning Records, Some Need To Be Detail Pages

New Here ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

508

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

this
<td>#rsDeptList.Department_Name#</td>
becomes somthing like
<td><a href="details.cfm?id=#department_id#">#rsDeptList.Department_Name#</a></td>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2006 Jun 30, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2006 Jun 30, 2006

Copy link to clipboard

Copied

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_Name#</a></td>
<td>#rsDeptList.Phone_Number#</td>
</tr>
</table>
</cfoutput></td>
</tr>
</table>
</body>
</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 30, 2006 Jun 30, 2006

Copy link to clipboard

Copied

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,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

LATEST
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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation