Inserting data into two related tables

admin

Administrator
Staff member
::: Warning newbie below :::

hi i was hoping you could help me understand how to insert data into two tables in a DB.
This is what i have so far, and its wrong.

$sql = mysql_query("INSERT INTO user, userfiles SET" .
"uid = $users.$id" .
"desc = $description" .
"filename = $filename");

do i need any WHERE clauses? how do i input into the uid field..i dont think the above is accurate at all.
below the tables are holding users and the other is holding there files. (just like the "jokes database" tutorial on devshed, if your familiar with it.)
anyway below shows the uid (user id) in the userfiles. id like to know how to use this when inserting into that feild. and any other info u can give me heh. thanks.


table 1. -USERS-

id | user | password | date |
1 | fred | pw | date |
2 | frank| pw | date |



table 2. -Userfiles-

id | filename | desc | date | uid
1 | filename1| desc | date | 1
2 | filename2| desc | date | 1
3 | filename3| desc | date | 2
 
Back
Top