Help in Javascript
Okay, i need some tips or if you wanna be nice enough to write out the code that would be cool….but anyway….me and a friend are starting a web site and we are gonna have this "news" section and we want to be able to write a article and give is a variable or date or something and we want a code that will output one of the articles depending on either most recent date OR largest variable….would i find this with Math.max, arrays, and variables? i need some tips please and some examples…this would be greatly appreciated…….peace
@Folk Theory: i'm sure gla di traded my dog for a scripting language then!
Couple things you'll need to know when doing this. For one, it will be done in PHP. Next, you need to know a few things:
- A basic/good understanding of PHP (it's not hard at all)
- A basic/good understanding of MySQL (again, not hard. you can get a free PHP host from places like www.789mb.com www.9999mb.com etc)
http://www.w3schools.com/php/php_ref_date.asp http://www.w3schools.com/php/php_mysql_intro.asp
Ok, now how I would write this is this: You can either upload a .txt file or w/e, or you can make an input field to type out the 'news'. Then, it will take you're article, save it as a .txt file, add it to your MySQL database, in one column you'll have the name, and in another column you'll use the getdate() function, and add that to another column.
http://www.w3schools.com/php/func_date_getdate.asp
Then, you can use a SQL SELECT statement that uses a WHERE to retrieve the newest uploaded article, and then echo it. You might also want to make some hr's, make sure it adds a date, time or whatever but that would be the basics of how I would go about starting to do something like that.
A bit off topic but… I remember my high school teacher had us build a menu driven help system to go with our major project for the year, and it had to be web based. So I went and asked him if I could use PHP, to which he replied "what is that?". After a short explanation he got confused and said that I could only use JS. So just to spite him I built the most obfuscated, long winded manual I could all packed into one gigantic JS file, that he had to read through and mark for content ( thankfully not coding style ;)). Unfortunately I've lost it now. (Lesson: back up your stuff!)