Question

I want to put a form on my website to let users add events to their private calendar. For that, I would like to create a new column in MySQL each time the user add an event (always with the same form, one column for each event title, for example...)

Is it possible?

Était-ce utile?

La solution

It is possible using ALTER TABLE

However, would it not be better to have a table called 'events' that holds all of them, with a column called 'userid' which contains the ID of the user the event belongs to.

Then you would know that every event exists in that table, and to get a users events you simply query that one table for rows that contain the users ID in the userid column.

Autres conseils

Yes, but it's a very very very bad idea.

Add a table userevents, add a record to that. To get the output you want, have look for how to do pivot queries in mysql.

For this type of app. You can use magic websql (client side database)!

Web SQL Database is a web page API for storing data in databases that can queried using a variant of SQL.

More: http://html5doctor.com/introducing-web-sql-databases/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top