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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.