Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> A Php Gallery Commenting Script Question..., i am working on a php script...
overture
post Mar 16 2005, 12:27 AM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 208
Joined: 6-September 04
From: England
Member No.: 315



Hi all, i am working on a Gallery commenting script for myself and i got stuck at a part of it. I would like each new comment added to an image to be a number as the text file name like 1, 2, 3. everytime they add a comment the next file name is incremented (+1) and so on for example; if there was a text file names '1' then the next would be named '2'.

I know how to create the file and the rest of it, but i would like to know how to do this. I should probably store the last file name somehow and then add 1 to it to create the next file but i do not know how.

Thanks

overture.
Go to the top of the page
 
+Quote Post
vujsa
post Mar 16 2005, 01:11 AM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 888
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714
myCENTs:35.43



php has a built in ID function that generates an alphanumeric value based on microtime.

See Also This Topic

Otherwise, if you really want 1, 2, 3, 4, 5, 6, 7, ...

You'll need to create a count file with one line in it.
The line will just be the current number of files saved.

each time you save the comment file, you'll need to open the count fill, read the value, add 1 to the value, write the new value to the count fill and add the new value to the end of your filename.

This would create something like:
comment1.txt
comment2.txt
comment3.txt

A little php formating would allow for leading zeros.
Like this:
comment001.txt
comment002.txt
comment003.txt
...
comment025.txt


I suggest leading zeros because sorting generally requires this because the following computer sorting issue:
1
10
11
12
13
14
15
16
17
18
19
2
20
21
...
28
29
3
30

Leading zeros eliminates this proble up to the number of leading zeros.
Example:
0001 is good up to 9999 before sorting problems occur.
001 is good up to 999 ...
01 is good up to 99 ...
1 is good up to 9 ...

So you'll need to kind of guess how many files you'll have.

This is kind of basic explaination of what to do, if you need more specific information like code samples, let me know.

I always feel better when I figure it out on my own than just being told.

Happy Scripting, cool.gif
vujsa
Go to the top of the page
 
+Quote Post
overture
post Mar 16 2005, 01:02 PM
Post #3


Premium Member
Group Icon

Group: Members
Posts: 208
Joined: 6-September 04
From: England
Member No.: 315



Thankyou vujsa, that is what i this morning before i came on here to check. I wouldn't have thought about the leading 0 so it counts ok, thankyou for that.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Trainable Anti-spam Filter Script(3)
  2. Php Script To Download File From Another Site(9)
  3. Need Help With A PHP - MySQL Registration Script(13)
  4. What Would Make A Good Registration Script?(4)
  5. Auto Responder Script(6)
  6. Installed A PR Checker Script - But Not Working Correctly(6)
  7. How To Delete File Using PHP Shell Script(3)
  8. Online Multiplayer Chess Script(2)
  9. Automated File Structure Creation Script(3)
  10. Authentication Script(1)
  11. Login Script(5)
  12. Please Help (php Join Script)(5)
  13. Automatic/remote Php Script Execution(9)
  14. Something Wrong With This Script?(9)
  15. Automated Product Suggestion Script(2)
  1. Run A Script When Expires A Session(6)
  2. Php Script Help(1)
  3. SQL Doesn't Connect In PHP Script(19)
  4. Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ...(4)
  5. Password Recovery Script(6)
  6. Login Script(8)
  7. Free Forum Hosting Type Script Help!(2)
  8. Script Request(2)
  9. Writing And Testing My Own Login Script [solved](20)
  10. Make A Script Run Even If No User Is Online(6)
  11. Php Login Script(0)
  12. Can't Make This Query Working.(2)
  13. Myspacetv Download Php Script Help(6)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 04:16 PM