문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top