What's the best and easiest way to create user profiles for a To Do List website that uses JavaScript and jQuery? [closed]

StackOverflow https://stackoverflow.com/questions/16866181

  •  30-05-2022
  •  | 
  •  

Question

I learned JavasSript, HMTL, CSS, and jQuery on Codecademy.com and began building a website that provides users with a To Do list that they can edit and sort. I coded it in Sublime Text and just have it on my computer currently.

My question is, what is the best and easiest way to store individual users' To Do lists (and some other information) so that they can login and come right back to that same list when they return to the site?

I really don't know anything at all about how to go about doing this so using as much plain English as possible in your response would be greatly appreciated.

I started taking a Codecademy course on Apigee's API, which seems to allow you to do what I am looking for but the course is not written very well and seems to have some bugs in it. I'm also not sure if using Apigee is the best way to go about doing this.

Était-ce utile?

La solution

Each user would have a row entry in your users table. You could have a very large text field (say, called ToDoList) and store each list entry as a string, with strings separated by a character of your choosing.

For example:

"Go to the store|Take dog to vet|Buy Dad a birthday card|Mail Dad's card"

When the user logs in, you would read that user's entry from the database, reading in that field.

$u = mysql_result(mysql_query("SELECT * FROM `users` WHERE `user_id` = '$user_id'), 0);
$toDoStr = $u['ToDoList'];

You would then explode the string back into individual array elements, using explode(). $arrToDo = explode("|", $toDoStr);

When the user is ready again to save his revised ToDo list, you could loop through the HTML fields and get all the values, and re-create this ToDoList string. Note that (upon saving to database) you would need to check each To Do List item for your separation character (in this example, the | char) and replace with a different character.

Autres conseils

I would suggest a simple SQL like database to store everything, with a table that holds an entry per user. SQLite ( http://www.sqlite.org/ ) would be a great database to use for your idea.

A library I have used previously can be found here: https://github.com/jhubert/javascript-sqlite

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