|
|
 |
| PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the PHP Databases section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

April 2nd, 2009, 11:51 AM
|
|
Registered User
|
|
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
linking tables
This is a student web organiser.
I really need help with this!!
Have THREE database tables
COURSEINFO---
Field Type
-----------------------
CourseCode varchar(10)
Semester int(1)
CourseYear int(1)
Day varchar(10)
Time varchar(5)
Subject varchar(100)
WEEKTIMETABLE
---------------
username varchar(10)
day varchar(10)
Time varchar(10)
Subject varchar(100)
CourseCode varchar(10)
Semester int(1)
CourseYear(1)
Userinfo
---------------
firstname varchar(15)
lastname varchar(20)
username varchar(15)
password varchar(20)
email varchar(20)
coursecode varchar(10)
courseyear int(1)
the user enters in all their details at regestration then they login into the system. I have all the seperate courses information in course info. The main aim of the program is to be able to make a unique timetable for each member. I want an php statment that transfers all the course info rows depending on what course and year the user picks during registration. However as there is no username in courseinfo and this is the unique idenitfier for the timetable and is necessary to extract it how will i do this???
not sure at all but something like
select username.userinfo , coursecode.userinfo , courseyear.userinfo , day.courseinfo , time.courseinfo, subject.courseinfo,
from userinfo and courseinfo
where username = (user that just registered) AND courseyear = (course that the user just entered) AND coursecode = (course code that user just entered)
and insert that select statement into the weeklytimetable table
is this possible or is there another way of doing it ?
example of tables
course info
----------
course code-CA316, CA316
semester1, 1
courseyear 1, 1
day MONDAY, TUESDAY
time 09.00, 10.00
subject LECTURE, PARTY
USERINFO
---------
firstname - john, paul
lastname - brown, murphy
username - johnb, paulm
password - ****, ****
email - ifi@fd , ds@fjd
coursecode- ca136, ca136
courseyear - 1, 1
WEEKLYTIMETABLE--
username - johnb, johnb
day -monday, tuesday
time -9.00, 10.00
subject -lecture, party
coursecode - ca316, ca316
semester -1, 1
courseyear -1, 1
many thanks for your help!its very urgent!!
|

April 3rd, 2009, 06:52 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2007
Location: , , .
Posts: 129
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I think your table design is not normallised. Your weektable contains same columns as you course info table. define primary key in course info and refer that key in weektable.
weektable may look like
username, courseinfoid
__________________
urt
Help yourself by helping someone.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |