macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Using 2 tables to edit db information

Subject: Using 2 tables to edit db information
From: "Irish-Phoenix"
Date: Thu, 17 Jan 2008 22:37:15 +0000 UTC
Newsgroups: macromedia.coldfusion.advanced_techniques

Hello;
 I am writting an edit form type section for a web site and it uses 2 tables. I 
have it done in pieces and now am working on sewing it together. Here is my 
problem.

 First I have 2 tables. One is Categories, and the other is Projects. here is 
what sections I have in these 2 tables:

 Categories Table:
 CategoryID
 Name
 MYFile
 Description

 Projects Table:
 ProjectID
 CategoryID
 Name
 Description

 I have 2 types of edit pages, one is for just adding and editing the Category 
Table the other to add and edit the Project table. Now what I am trying to do 
it the following. (I am going to break this down into parts, doing one part at 
a time. So this is a multi part question) I want to take the Project page and 
have the Category Name be the order by for the page, wich means I need an 
innerjoin. I am kind of at a loss how I would write that and still be able to 
edit the record without the innerjoin getting in the way. (This will also be 
used on the Category page as a nav link to edit all the projects with the 
corresponding category and that will be the only projects that will appear is 
the ones assigned to that category.

 But first I need just to ORDER BY Categories.Name in my Querry so that if you 
just choose to go to this page and view / edit all categories you can.

 Here is my code so far. I need to have the Project manager page organize all 
the projects by Category.Name

 <cfquery name="proMan" datasource="#sitedatasource#" username="#siteUserID#" 
password="#sitePassword#">
        SELECT Projects.Name AS PName, Projects.CategoryID, Projects.ProjectID 
AS ID
        Categories.Name AS CName, Categories.CategoryID
                 INNERJOIN Projects ON Categories
                 FROM Projects, Categories
 </cfquery>
 <head>
 </head>
 <body>
 <cfoutput query="proMan">
 Project Name: #PName#
 Project category: #CName#
 <form action="Project-Action.cfm" method="post">
                     <input type="hidden" name="ID" value="#ID#">
 <input type="submit" name="proj_Edit" value="  Edit  ">
 <input type="submit" name="proj_Delete" value="Delete">
 </form>
 </cfoutput>

 I know this is wrong, so How do I make it work? 
 (Then I will go into the next phase of the question about being able to go 
from teh Category Manager page to edit the projects just associated to the 
respective category, unless it is easier to do that part now. Then I will post 
the code from the Categories page so we can do an innerjoin there and make a 
link to edit projects in that category.)

 Thank you. I know this is conveluted, but it is a big section and a lot of 
little odds and ends to tie in.

 Phoenix
 </body>



<Prev in Thread] Current Thread [Next in Thread>