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 trialGeorge Michael
1,783 PointsPHP how to create clickable filters and allow user to modify data base trhough forms
Hi ! i'm creating a website were users can add music through forms that everyone can see in the library. They can modify and also delete those musics, through a button. In this library users can click on "filters" (title, mark, style, etc...) to find more easily what they are looking for My problem is that i'm really new to php and mysql and i have no idea how to do it i have already created the website in html/css (with all the inputs) now i need to make "alive".
to sumerize :
- how can i make it so people can upload files to the database and also give them names that will appear in the library and that the filter is going to use, through forms ? (title, etc...)
- I need help with the filters so they can sort the musics between themselves if you click on them (the filter "title" will sort music by their title)
6 Answers
Carlos Alberto Del Cueto Carrejo
13,817 PointsI would suggest you to complete a couple of courses which should aid you in building the app that you want, first do this one : https://teamtreehouse.com/library/integrating-php-with-databases It will aid you to connect the database to your site and query what is in it, you will have to make a connection to your database, make sure you can read it, from there fill the form fields with values of the database. Watch this one too: https://teamtreehouse.com/library/build-a-basic-php-website There is a topic about PHP forms which will aid you in creating a responsive form, after that you will have to fill in the form values with the values from the database. To upload files to the server you can use third party libraries. To be honest you question is quite broad and can be overwhelming if you are just getting into PHP and MySQL, hope this helps you out.
George Michael
1,783 Pointsso i watched some videos and gave me ideas about the filters i'm thinking that if you click on a filter it will actually change the page to another one that is pretty much the same but with the medias rearranged according to the filter type but isn't there a more simpler solution ? because if i want to make it possible to activate multiple filters i have to create as many page as there are combinations (wich doesn't seem very pratical...)
about the user able to add content himself i'm still stuck tough i'll try to advance a bit more in the courses but they are pretty hard now ^^
Carlos Alberto Del Cueto Carrejo
13,817 PointsI was trying to give a general idea, which you seem to grasp already. If you don't want to create so many pages you can take a dive into Javascript which will help you change the content on-screen without reloading the page, if Javascript won't suffice you can use AJAX, this one will allow you to somewhat merge PHP and Javascript to give you that functionality. I would suggest you to continue on with PHP, there are still a lot of powerful tools that you can learn with it, and the transition to another language should not be all that difficult. Keep on coding, try to keep the momentum , the drive and you will succeed. ;)
George Michael
1,783 PointsYay ! :D yup exactly what i'm doing, JS. i have my dose of php for this week haha i'll get back to it next week but i have to say it's pretty similar to JS in the way you write it ! thanks a lot :)
George Michael
1,783 PointsJS is actually more easier to understand, we pass much more time on the conditions than in php !
Carlos Alberto Del Cueto Carrejo
13,817 PointsThere are time you will need to do some conditions on JS, it is good that you are getting a hang on the language. if you continue on the Javascript track you will end up creating a MEAN application, something I haven't really focused on, but a great way to compete nowadays. A couple of my friends are really proficient in AngularJS and I must say it really pays off.