Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Adam Romański
Adam Romański
8,568 Points

jQuery working with database at localhost

Hello everyone!

I have a problem with my localhost database. Actually, i dont understand how it supose to work. Localhost is working when im running simple pages or making simple AJAX requests like importing external html files.

But what should i do if i want to create a form that will save some data in database? I've installed mysql and phpmyadmin (i'm using Mac Os X 10.10) , but i have no idea how to connect database with .js or .html file. Sorry for being such a lame, but i can't find answer anywhere. Do i need to learn PHP or Ruby on Rails before i will be able to do such things?

1 Answer

Ben Attenborough
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ben Attenborough
Front End Web Development Techdegree Graduate 32,769 Points

I'd recommend learning some PHP in order to access the database, there are some good courses including the main track: php development track which goes into a lot of detail and within that track there are two courses on databases, database foundations and Using PHP with mySQL Although it is a long winded way of learning the subject.

Databases are stored on a server, therefore you need a server-side language such as PHP, Ruby or ASP to connect with it. See the answer here on stackoverflow for more on why javascript isn't the way to interact with databases.

Adam Romański
Adam Romański
8,568 Points

Great answer Ben! Thank you very much :) I'll just finish my front-end developement track and try to understand the back-end part with PHP and Ruby.