Current location: Hot Scripts Forums » Programming Languages » PHP » User Text Input


User Text Input

Reply
  #1 (permalink)  
Old 04-11-04, 12:37 AM
D_tunisia D_tunisia is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
User Text Input

Don't laugh! I'm sure this is very simple for many people, but if you can help I would be so greatful!

I've create a SQL database which contains two tables.

1 table holds user information (usernames, passwords, emails)

The other table I want to hold text inputs from the user (they will go to a page and enter text, this will then be held in the database and referanced to their username for access later)

I've got the user registration and logins working really well, however I am now stuck on the text input part. Can I "include" more that one table in a page when I do my INSERT, or am I going about this the wrong way?

I need to edit both tables at the same time. Is this possible?

Thanks in advance to anyone who can help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-11-04, 01:45 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

As for the INSERT, you need to excute it record-by-record, so to speak, if there are 3 records to be put into the database for the user "foo", then you have to have 3 separate SQL statements (i.e. INSERT):

Code:
INSERT INTO user_input (Username, Input1, Input2, ... InputN) VALUES ('foo', 'blahblah1', 'hogehoge1', 'daradara1', ... 'booya1');
INSERT INTO user_input (Username, Input1, Input2, ... InputN) VALUES ('foo', 'blahblah2', 'hogehoge2', 'daradara2', ... 'booya2');
INSERT INTO user_input (Username, Input1, Input2, ... InputN) VALUES ('foo', 'blahblah3', 'hogehoge3', 'daradara3', ... 'booya3');
The same holds true for UPDATE statements. If you need to update 2 tables "at the same time", you run sepatrate queries sequentially. The only time you can automatically update more than 1 separate tables that I can think of is when you impose foreign key constraint CASCADE ON UPDATE, but this will only update your key(s) and not the other values.

If you insist you can look into transaction. With transaction, you can excute multiple SQL statements as if they were one SQL statement (rollback upon failure). BUT if you're dealing with only two tables and they are not auto-numbered, I guess it'd be an overkill. More info here: http://dev.mysql.com/doc/mysql/en/In...ion_model.html

Good luck.
__________________
Blavv =|
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to validate mutiple rows using the same input text Han84 JavaScript 1 08-02-07 10:14 AM
MySQL Query problem Wraith PHP 5 03-06-04 06:16 PM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 07:02 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 08:19 PM
How to enabled or disabled input text using a checkbox Han84 HTML/XHTML/XML 1 10-13-03 09:46 AM


All times are GMT -5. The time now is 11:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.