Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Look for a tutorial on databases, you look like you really need one.
Like this one: http://www.sqlcourse.com/
In a relationnal database, what you are looking to do is the base of the system.
You told us that you had 2 tables, users and data.
I'm starting from the principle that a user that is registered in your system have an id.
I'm considering that those users can save datas in your database, and that those datas will have something that will link them to a user.
The step to put everyting together are called "joins". You will tell the database engine that you want to join the inforamtions from the 2 (can be way more than that) tables to display only some that correpond to the filters you will define.
Supposing that your tables look a bit like that:
Code:
users:
id integer
username varchar
datas:
id iteger
user integer
data1 varchar
data2 varchar
In this case, the link between the datas and the users would be the field datas.user
Being an integer, it would mean that the value in that field would match the users.id field, telling that the row X in table datas have been created by the user n° Y
As you already know, you can do 2 select, and parse them in php.
But you can join the tables on that common field too, like this
Code:
select users.username, datas.data1, datas,data2
from users
inner join datas on datas.user=users.id
But I urgently recommand you to follow the tutorial I've gived you, you relly need to strenghten your sql knowledges if you are to be working with databases.
from
__________________
Only a biker knows why a dog sticks his head out the window.
Last edited by tripy; 11-01-2008 at 02:28 PM..
|