Results 1 to 5 of 5

Thread: PHP prob

  1. #1
    Join Date
    Mar 2002
    Posts
    376

    Question PHP prob

    I just learned the basics of PHP and I decided to make my first script to get the hang of it. The script is designed make updating the news section on my site easier. I have a submit form that makes a variable = to all of the information (date, author, ect.) of that post and adds it to an array called postarray. When I add a post to the array it gives it the next available value instead of the 0 I want it to be given (In other words I want the newest posts to print first, then the older posts in that order).

    I also have another problem. I want the array to delete all posts after... say the 20th post. How can I tell the array to delete all posts after they are given a value greater than 19?

    Or am I just going about all this wrong? Im sure there are plenty of scripts like this but its not fun to copy paste other peoples scripts =(. Thanks!

  2. #2
    Join Date
    Mar 2002
    Posts
    376

    um?

    ouch, nobody knows?

  3. #3
    Join Date
    Jan 2002
    Location
    Atlanta, GA
    Posts
    1,249
    Well... I recently learned PHP,... And the problem is...

    It's simply a browser (actually server) side single state script. I.E. it only exists (runs) at the time the page is called.....

    To do what your talking about you need to learn MySQL.... Once you get the hang of php MySQL should be very quick to pick-up...

    BTW... It's a database so you can store and retrieve items like News Stories etc... so you don't have to hard code them into your pages.

  4. #4
    Join Date
    Aug 2001
    Location
    United kingdom
    Posts
    1,003
    Radix, it's easier if you use MySQL, as Studio64 has already mentioned. The way you are doing it now (if I understood correctly) is not really efficient, and it's probably harder to do.

    If you use a MySQL database, all you need to do is to get your form to submit the data into the database, and then on the page that shows you the news, just get it to retrieve the latestnews from the database... you can get it to show the newest news first and then the next latest one etc... and also you can set it to display a maximum of 20 news items only.

    Alan
    Alan Ho
    Former Systems Administrator

  5. #5
    Join Date
    Mar 2002
    Posts
    376

    your right

    I just got a copy of apache and i got someone who said he would help me with MySQL. He said I didn't have to use a database but it would be easier if I did (pretty much what you guys are telling me). Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •