-
two databases
gud day everyone,.
my program is using two databases; the one database is for other details and other is for the names and account id of the said details
my problem is when im only retrieving the two fields from the other database my program gets crushed,.
but when im only retrieving the account id, i got no errors at all,.
my question is, is it because i got two databases? or is it because my script got a long algorithm?
but when im trying to run it with two separate programs it is working,.
eg. a page that retrieves the account id and the names - it works
the other page is for the details - it works,.
thx in advance,.
i hope you got my point ^_^
GOD bless
more power,.
regicide del feroz
-
This would be hard to say without seeing the code. Now are you actually talking about 2 separate db's or 2 separate tables within one db? It's not common practice to have more than one db per site. If you're getting info from 2 separate tables in one db then you could look into JOIN to help make it one query.
-
thanks for the reply,.
sir, i'm getting two separate dbs,. because they are from different categories,.
i already tried to combine them in only one db but still i got the same problem,.
what do you think sir?,. is it with my codes?
-
-
I can't imagine a situation where you would require 2 separate databases. You haven't really provided enough information for anyone to help you, but my guess would be that the problem stems from the tables not being in the same database. You just need to add a category table. What are the items that are in the categories? What are you dealing with? That would help shed some light.
It just sounds so wrong to have the account_ids in one database and then the details in a separate database that are presumabley identified by the account_id in the other database. Is that even possible?
-
You can use one database with multiple tables. It will be much easier. Is there a reason that can not work?
-
i already tried them in using one database but i still got the same problem,.
-
And we have yet to see the problem. What does it mean that your program gets "crushed?" Please show us your code and the table structures in your databases. One of the geniuses on this forum would have had your problem solved already if they had some clue what you were doing.
-
i mean crashed,.
on the first table:
|----------------------|
| ID | Account_Name |
|----------------------|
| 1 | Coca Cola |
| 2 | Mountain Dew |
|----------------------|
table 2:
|-------------------------|
| ID | Size | Price |
|-------------------------|
| 1 | 8 oz. | Php 8 |
| 1 | 12 oz. | Php 12 |
| 2 | 12 oz. | Php 14 |
|-------------------------|
the output that i wanted to be is:
|---------------------------------------|
| ID | Account_Name | Size | Price |
|---------------------------------------|
| 1 | Coca Cola | 8 oz. | Php 8 |
|<no value>|<no value>| <br>12 oz. | Php 12|
| 2 | Mountain Dew | 12 oz. | Php 14|
|----------------------------------------|
*Php stands for Philippine Peso
hope you understand,. i can't format the table because our forum does not support
nor [pre][/pre]
thanks
-
Thank you. This should definitely be done using only one database. Think of it this way.
product table
product_id | product
---------------------------
1 Coca Cola
2 Mountain Dew
inventory table
product_id | size | price
---------------------------
1 8 oz Php 8
1 12 oz Php12
2 12 oz Php 14
Code:
SELECT t1.product_id, t1.product, t2.size, t2.price FROM product t1, inventory t2 WHERE t1.product_id = t2.product_id ORDER BY product
There is a one-to-many relationship between the product and inventory tables. Generally you store the data in the tables in a concise form (no redundant data) and then use reports or scripts to format the output so that it looks nice with non-repeating headings and such. In other words, you use SQL commands to retrieve the data from your tables but you format the data for display on a website, or to print a report, using php and html or some other scripting language. I'm sure Daniel or one of the other geniuses can explain this much better than I.
-
thanks for the solution,. i'll try this one,.
thx
God Bless
-regicide
-
thanks for the solution,.
anyways..
do you know how to answer this one? hehehe:
http://www.dynamicdrive.com/forums/s...862#post255862
more power
-regicide