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
Soheil Gheytarani
34 Pointsa "count me" site!
Hi! I want to make a single page with a big " count me, too" button in it that everybody comes and if he/she agrees to the text on site, just hits the button and the Big number which is shown in the page gets higher! just that much simple!
I've wrote the HTML & CSS, but I don't know how to do the rest.... I want to track the Date, hour, IP and the times that that person hit the button. and of course a way that if he was attacking the site, that specific part of site, became inaccessible for him/her.
I've heard of Databases, but I don't know how to save things like that in one and access the Stats in a visual way (charts)
What language should I use? What are the main codes?
Since I have to finnish this little project till Friday, I'd be happy if you help
If you need to see the web Design, Just tell me...
Thank you in advanced
5 Answers
Perry Clark
8,261 PointsI believe PHP would be your answer.
http://teamtreehouse.com/learning-adventures/become-a-php-developer
Soheil Gheytarani
34 Pointsthank you... I've checked them out very fast but there was no talking of data storage, I guess...
could you be more specific... I mean what code can help me to store data in MySQL? and how can I get those data back in my Panel and visualize it... what is the best way?
I mean when there is going to store a specific "Date" maybe 1000 times a day, maybe storing it once (0000-00-00) and calling it thousand times (0) will reduce the amount of data on DB... Am I right?
ha?
Randy Hoyt
Treehouse Guest TeacherThis is some pretty sophisticated functionality. I would build it with PHP and MySQL, but it sounds like that's probably not something you could have ready by Friday. You might instead want to check out a hosted form service like Polldaddy or Wufoo. You could build a simple form or survey, maybe with one "I agree" checkbox field and a button.
J.T. Gralka
20,126 PointsSoheil,
I commend you for taking on such an ambitious project!
For starters, I think Andrew Chalkley here at Treehouse has plans of coming out with a database course in the next few months, but as Perry points out, you'll also need to feel comfortable working with PHP to write this program. So, there are really two things to think about:
- your database entity relationship model, and
- how your web application will interact with that model.
I'm going to try to paint some broad stokes to give you an idea of the things you'll need to understand in order to get started on this project. But first, I should mention that I'm going to be speaking in terms of PHP and MySQL, although there are tons of other terrific language/database combinations -- PHP/MySQL is extremely popular!
What Your Database Might Look Like
You're right to assume that you'll need to design your database in a way that eliminates as much redundancy as possible. This is usually referred to as "normalization". I could imagine a scenario in which you might have as few as two tables in your database:
- a table that stores information about the articles you're posting, and
- a table that stores information about the "count me ins".
The article table (we'll call this tbl_article) might contain a few different fields that relate to each article. For example, article title, article text, article author, URL to full text, etc. But, it would be important to also give each article in your tbl_article table a unique numerical index (sometimes called a "surrogate primary key"). This primary key will be used in the count-me-ins table (which we'll refer to as tbl_count) to refer to the article anytime someone decides they like the text. This prevents duplicate entries in tbl_count from each containing a large amount of text.
tbl_count might contain the following fields: an article's id, the IP of the user, and a timestamp. If you structure your MySQL table correctly, your database will efficiently reference the article information from tbl_article.
In terms of normalizing out the date/timestamp, I would actually suggest that you not do that. Even though, there will likely be a lot of entries to tbl_count, it might be helpful for you to analyze which IPs liked which articles and which times.
How PHP Can Help
I encourage you to look at the improved MySQL suite for PHP on PHP.net to learn about how to integrate your MySQL database into your PHP application, but I think you'll find that, once you start learning how to design and query your database for information, the PHP will start to come together.
An Apology
I threw a lot at you in this post, and I apologize if I overwhelmed you. This post was extremely incoherent, and if none of this clicked, please let me know and I'd be more than happy to clarify. I realize that most of my explanation was pretty hand wavy and used a lot of terminology with which you might not be familiar. In short, I encourage you to start thinking about your database model first -- even if you aren't comfortable with writing the MySQL DDL quite yet. -- And when you are, let us know! :-)
Best,
J.T.
Soheil Gheytarani
34 PointsAt first I'm thankful of you... I hope one day I be able to return the favors ....
@Randy Hoyt :
Using a sites like Polldaddy is an option, but not a good one....
@J.T. Gralka :
no apology needed at all... I appreciate your help... I must say I used to spend a lot of time in MS Excel or Access and I know a little about Data Storage... but the problem is where to start... right now I'm working on it and when it's done, I'll publish it on my niece Site mhm5000
I'll make a PDF of DBs that I'll create, and wait for you guys to help me! ;)
I found this for IP: