Web Hosting Talk







View Full Version : PHP prob


Radix
06-07-2002, 07:05 PM
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!

Radix
06-08-2002, 12:43 AM
ouch, nobody knows? :confused:

Studio64
06-08-2002, 01:24 AM
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.

ho247
06-08-2002, 06:30 AM
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

Radix
06-08-2002, 04:12 PM
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.