Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Automate new html tables focussing on info in a database.

Status
Not open for further replies.

zndow

Technical User
Apr 5, 2005
16
CA
Hi !

I need to add tables in my .cfm where access database info are stored. I am creating a new table for each new compagny.

My problem is to make it automatic. When i insert new compagny in the database i want that .cfm page to add a new table and add it under the other compagny tables.

I need the coding to recognize the number of compagnies and create a table in my .cfm page for each of them.

For now my access database is made with a column name Brand, and theres lot of duplicate names cause its not a primary key.



 
Why are you keeping a seperate table for each company? It would be better (and much easier) to keep all of the companies in one table. Can you give us some more details?



Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
I know it will be much more easy in one table, but the boss want it the other way hehe.

AS more details i donnot see what else i can say. Theres nothing else special about it. Just need to find a way to auto create the tables starting from my access database compagnies name.

I did my page that way:

CFquery1.......................
CFoutput............
Compagny table1..........

CFquery2..................
CFoutput...............
Compagny table2.......

I cant type coding for each page everytime a new compagny name is add in the database. This will make me crazy in no time lol.
 
In reality after thinking maybe just a loop of the table will suffice, but i need to find the way to change the name of compagny at the compagny name in the table till all compagny names are pass out in the database. It will have the same look.
 
Now i think i got something. Tell me ECAR if it can work.

<!--- getting off the duplicated names --->

<cfquery name="query1" datasource="mydatabase">
SELECT DISTINCT brand
FROM mytable WHERE colomn1='productname' OR colomn1='productname'
</cfquery>


<!--- Loop changing brandname each loop step
and insert result in the table--->

<cfloop ="query1">
<cfquery name="query" datasource="mydatabase">
SELECT colomn1, colomn2, colomn3, brand
FROM mytable WHERE colomn1='productname'OR colomn1="productname" AND Brand='brandname'
</cfquery>

<table>
<tr>
<td colspan="3" align"left"> #brandname#</td>
</tr>
<tr>
<td>#field1#</td>
<td>#field2#</td>
<td>#field3#</td>
</tr>
</table>
</loop>

Is a coding like this could give me the result of having number of tables = to number of compagny names regarding my WHERE clause with the right informations in each tables.
 
tell your boss a seperate table isn't how a good database would work. a single table with ID's is the best way to do it.

doing it that way is just going to cause unneeded join problems. not to mention creating a query that is dynamic enough to get all the table names in it to join when the boss wants to know, "who's using x service" bad idea. try to educate him/her.

Beware of programmers who carry screwdrivers.
 
I am totaly with you on it SimulatedFun but my boss is kind of person who think he know everythings, and he think this is not harder then anything else and he dont understand why i could not do it when i can make a popup window to show only simple info from a database.

Why i would not be able to do the same balh blah blah.

I think you got the point. I told him, if its so easy and you have the answer then do it lol.

I think its over for me.
 
That wasn't the smartest thing in the world to do. But it isn't any worse than telling your boss "You run the company, I'll run the website. I agree not to make you run the business my way and you agree not to make me run the website your way." He was upset but when he saw it work he let it go... I never worked for him but he's still a client after a couple renewals.


It's hard to tell a boss like that "your way isn't always best."

Beware of programmers who carry screwdrivers.
 
Is your boss ever going to see the database? If not, build it however you want to and if it works he won't care.



Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
No biggy guys the compagny was not even started, i dont mind to let it go. I dont want to get up in the morning and have to say, hope i will not have to arguement today.

Its like having a baby, the next day the baby still there, if you dont want it like this then dont make it.

Its not officially over, but if you see me again asking help then you knwo its not lol.
 
hey man... an argument a day, keeps the steady paychecks away... hehe

Beware of programmers who carry screwdrivers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top