Welcome to the Treehouse Community
Looking to learn something new?
ben pines8,389 Points
Where in the wordpress database should I place a timeline of dates and data?
I am trying to create a timeline of a user's weight. Where in the wordpress database should I store this? in a new table? in an object? in the usermeta?
Rich Inman2,173 Points
I think that the best place for this would be in a custom table. You're going to have to set up a one to many relationship for this and I just don't think doing it with user meta would be very efficient.
Just create a new table with a user_id column that you can use to reference.
When you create the list you can then just query like this:
SELECT * FROM user_weights WHERE current_user_id = user_id ORDER BY desc;
This should give you every record in the table that's associated with that user sorted by most recent entries. It will all come in as an associative array if you use the most up to date php syntax for the query so it should be easy to parse.
Obviously use your own names for the tables and variables, but you get the idea.
Trying to pull in user meta would be a more difficult task I think. I hope this was a clear response, and if you decide to go this route and need some php examples of how I've done this before I'd be more than happy to provide them.