2 Replies - 689 Views - Last Post: 19 April 2012 - 05:35 AM Rate Topic: -----

#1 umarraidhan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-April 12

want to create a table after user has logged in

Posted 19 April 2012 - 04:37 AM

i am new to php i have got a log in and register page on my site which works. however i want to create a a new table once the user has logged in he can access but it only brings up the users details. i want to save his previous locations. if i create a table location where he can add his locations what fileds will i need to have in the tables and how i be able to bring up his details only.
Is This A Good Question/Topic? 0
  • +

Replies To: want to create a table after user has logged in

#2 Atli  Icon User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4238
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: want to create a table after user has logged in

Posted 19 April 2012 - 05:33 AM

View Postumarraidhan, on 19 April 2012 - 11:37 AM, said:

however i want to create a a new table once the user has logged in ...

This is a bad idea. You should not need to alter the structure of the database when inserting new data. The database structure should be fixed, with the new data being placed inside the existing tables.

If you, for example, want to store a list of location and which of the users has been to what location, you would typically set that up somewhat like this:
Users:           UserLocations:      Locations:
+----------+     +-------------+     +---------+
| id       |>--->| user_id     |  |-<| id      |
| name     |     | location_id |<-|  | name    |
| etc...   |     +-------------+     | etc...  |
+----------+                         +---------+


There each user has an entry in a User table, and each location has an entry in a Locations table. Then each Location each User has been to would be logged into the UserLocations table, which links back to each of the other tables with a FK.

Note that you could change the "UserLocations" table pretty easily to allow each user to log each location multiple times as well.

If this seems overly complicated, I suggest you spend some time studying basic design of relational databases. It's important to get the basics down before you start using them, or you might suffer for it later.
Was This Post Helpful? 1
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3714
  • View blog
  • Posts: 13,472
  • Joined: 08-August 08

Re: want to create a table after user has logged in

Posted 19 April 2012 - 05:35 AM

That would go something like this:
if($user->loggedin()) {
  create_table();
}


Now all you need to do is create the user class and the function to create the table!

Edit: Atli is right. I misread your question and thought you wanted an HTML table.

This post has been edited by CTphpnwb: 19 April 2012 - 05:37 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1