Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Help in Javascript


ghost's Avatar
0 0

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


richohealey's Avatar
Python Ninja
0 0

if i'm understanding you correctly this needs to be done serverside… so js is NOT your friend


ghost's Avatar
0 0

php in the other hand is man's best friend.


richohealey's Avatar
Python Ninja
0 0

@Folk Theory: i'm sure gla di traded my dog for a scripting language then!


ghost's Avatar
0 0

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:

  1. A basic/good understanding of PHP (it's not hard at all)
  2. 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.


ghost's Avatar
0 0

thanks guys i was really hoping i wouldn't have to use php i have NEVER looked at it i have glanced at SQL i even bought a book about it but i didnt really get it…..but i figured the answer would be in php…..peace


ghost's Avatar
0 0

using js for something like this is something u would write fr someone your pissed off at just to give them hell


ghost's Avatar
0 0

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!)