Gossamer Forum
Home : Products : DBMan : Customization :

multiple db single output

Quote Reply
multiple db single output
I've been reading FAQ's and have some ideas of what needs to be done, but I'm not sure how to pull it off (in case anyone hasn't realized the obvious, I'm not much of a programmer Frown just a quick learner).

Anyway, I need to pull up a single page that has info from two seperate .db's

eg: Name & Address from db1 and Field1 and Field2 from db2.

Rather than grabbing specific fields to display, I would like to have all fields available, because I will probably use them all somewhere.

Userid is key field in both db's

Help is much appreciated! Smile
Adam

Quote Reply
Re: multiple db single output In reply to
This is sort of like the relational database thing. I think. Smile

How will you know which record to pull up? Is this from a search or is it the user's information?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: multiple db single output In reply to
Ahh, sorry.....my mistake! Userid is NOT a key field in both db's. (I don't know what I was thinking about when I said that).

Userid is a key field in the users information db. The other db has many records per user.
The user will just click a link, like view, and then it will list all the fields that I have predefined and formated.

This is actually related to my other outstanding post on calculations.
http://gossamer-threads.com/...ew=&sb=&vc=1

I need it to make the calculations before posting the second db's information to the browser along with the user information db.

Adam

Quote Reply
Re: multiple db single output In reply to
Okay, then. This is *exactly* a relational database. Smile

Have you read through the relational tutorial I have at http://www.jpdeni.com/.../Mods/relational.txt? This will give you some idea of where we're going with this. I've worked a lot of people through this, so I have no doubt I can work you through it too. Smile

Once we get the data through the relational thing, we can work on your calculations. Deal?

(Yes, I thought your other post was outstanding, too. One of the best posts I've seen. Wink Seriously, I read it and thought that the problem was solved. But it looks like I was mistaken. Smile)

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: multiple db single output In reply to
Smile Thank You very much, Thank You very much...I pride myself on being able to offer these outstanding posts on a regular basis! Smile

Ok, it's a deal. I'll read some more through the relational tutorial and then we'll work through this, then the calculations. First, I think I'll figure out the other thread we have running so I don't confuse anything. Smile

I'll post here again at a later date when I've advanced through tutorial.

Adam

Quote Reply
Re: multiple db single output In reply to
Ok, I read through the relational tutorial and now have some things to go through, and ask.

I have two db's. Both will have records with Userid in it. In one db this is the key field (so i guess that makes this db the one side). The other db will have ID#'s as the key field, and Userid as another field. This will be the many side because Each userid will have many ID#'s associated with it.

In Reply To:
You can not use the autogenerate feature for this modification.
Why exactly is that? And does this only apply to forms for inputing and not viewing?
If only for inputing, then no problem!

Let's move on to say that I would like to be able to have all fields available from both db's for my output.
Is this possible?

Here is some more detail......
2 db's - one is user info with fields like name, address, email, etc.....
The other has info looking like what I put in my calculations question
ID Userid Field1 Value1
1 xyz item1 100
2 xyz item1 100
3 xyz item2 200
4 abc item1 100
5 cdf item2 200
6 cdf item2 200
7 cdf item3 300

This info needs to be displayed two ways. First as the calculation -- See:
http://www.gossamer-threads.com/...ew=&sb=&vc=1
Then as itemized, like above, however only those records that match the current user (only view own records) can be viewed.

So for user 'cdf' I will end up showing:
User: cdf
Real Name
Address
Email Address
item1 Total 0
item2 Total 400
item3 Total 300
Grand Total 700

Or, there's the option to view it like this:
User: cdf
Real Name
Address
Email Address
item2 200
item2 200
item3 300
Grand Total 700

Probably ignoring the calculations for now, and just getting to the point that I can show the itemized (without grand total) to start......what should I do?

I'm going to keep reading over the tutorial for now....

Thanks!
Adam

-------Added to post:
Is it possible to have a single html.pl? Or, should I have one html.pl for the calculated one and then another for the itemized one?
Quote Reply
Re: multiple db single output In reply to
In Reply To:
You can not use the autogenerate feature for this modification.

Why exactly is that? And does this only apply to forms for inputing and not viewing?
If only for inputing, then no problem!
No, it's for viewing, mostly. Could be for inputting as well.

I guess a lot depends on what you want to do. The normal use of a relational database is to either

-- print out the record from the "one" side and then list the related records from the "many" side, or
-- print out one record from the "many" side and add information from the "one" side to the display

In order to do either one of these, you have to do coding within sub html_record. If you have the autogenerate feature on, it doesn't even look at any coding within sub html_record.

In a nutshell, if you want to display records from both databases, you cannot use autogenerate. But I haven't read the rest of your message yet. Maybe you don't need to display them both.

In Reply To:
Let's move on to say that I would like to be able to have all fields available from both db's for my output. Is this possible?
Ah. There's my answer. Yes, it is possible -- but not with autogenerate.

In Reply To:
Is it possible to have a single html.pl? Or, should I have one html.pl for the calculated one and then another for the itemized one?
You can put them both in the same file. In fact, you can put them both in the same subroutine, which will save some coding.

Let's start with the "itemized" one first, with no calculations. It won't be hard to make the calculations, but it's best to go one step at a time.

The first thing you'll need to do is set up the "switch_to_" subroutines as outlined in the tutorial. These have to be done carefully, with the fieldnames exactly as they are in the .cfg file.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: multiple db single output In reply to
OK. autogenerate is off (actually always has been but now I know not to turn it on Smile )

It'll take me a little while to setup the subroutines from the tutorial.....but I shall be back.

Thanks!
Adam

Quote Reply
Re: multiple db single output In reply to
Well I made it through setting up the switch_to in db.cgi, now for the next step.

Your tutorial has an example for setting up the one side (and listing the many) and then a single record on the many side (and listing the one). I guess my itemized would fall under the one side (and listing the many, although not just a link...the entire db).

I'm going to go safely try it on my own....if you have any words of wisdom let me know!

Thanks
Adam

Quote Reply
Re: multiple db single output In reply to
OK. I think I got it now.

It prints out on the top of the page the users info that is logged in.
And then below that it prints all the records that user has.

I think we can now move on to the calculations....I'm getting the hang of this relational stuff.

Thanks!
Adam

Quote Reply
Re: multiple db single output In reply to
Excellent!!!! Smile

It's all pretty logical, once you start understanding the syntax.

Will now switch to the other thread.

JPD
http://www.jpdeni.com/dbman/