Jump to content

Create File Increment


Karir

Recommended Posts

Hey!

I am making a comment system for my blog I'm making.

The way I want it, is that when a comment is posted, it grabs the id of the post it's referring to, then creates a file called comment(POST ID HERE).txt..

I have that down, however I cannot for the life of me figure out how I can make it an increment, so it can make no more than 500, but everytime a comment is posted it will keep making the files go up like:

comment1.txt

comment2.txt

comment3.txt

 

Etc...

Thanks very much, happy holidays! :D

Link to comment
https://forums.phpfreaks.com/topic/222180-create-file-increment/
Share on other sites

The way I want it, is that when a comment is posted, it grabs the id of the post it's referring to, then creates a file called comment(POST ID HERE).txt..

That means that a post will only be able to have one comment. Is that really what you want?

 

however I cannot for the life of me figure out how I can make it an increment, so it can make no more than 500

With the way you're doing things, you're going to have to keep a designated file with a number in it, and increment it when a comment is posted. Or iterate the folder and count how many comment files there are.

 

Why not just use MySQL for everything? You could have a posts table and a comments table. And have it  be a one to many relationship.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.