Sure, my database looks like this:
1st table - users:
Code:
Field Type Null Default Auto_increment
user_id smallint(5) No yes auto_increment
email varchar(40) No
password varchar(40) No
first_name varchar(15) No
last_name varchar(30) No
active char(32) Yes
registration_date datetime No
2nd table - temperatures:
Code:
Field Type Null Default
user_idm smallint(5) No
temp_rating char(2) No
notes text Yes NULL
time_entered datetime No
time_entered2 timestamp No
CURRENT_TIMESTAMP
When I say that I 'use sessions' to link the user_id to that user's records in the data table, I just mean that I use the following query to add user_1's records to the data table. It depends on there being a session and it uses the session data. That is, if there weren't a session, I would have no way of entering data into the temps table.
Code:
$query = "INSERT INTO temps (user_idm, temp_rating, notes, time_entered)
VALUES ('$_SESSION[user_id]', '$temp', '$notes', NOW())";
if (@mysql_query($query)) {
print '<p>The entry has been added!</p>';
}
Bookmarks