Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
A bit of help with a simple threaded PHP board needed
Old 08-13-2004, 08:49 AM A bit of help with a simple threaded PHP board needed
Novice Talker

Posts: 6
Trades: 0
Hello. I'm a total beginner with PHP. I need just a tiny bit of help with a simple threaded PHP forum. I've asked for help elsewhere, but didn't get detailed instructions... Again, I am a -total beginner-. I'm not making money with my site, I use the forum for talk with a couple of my friends. While setting it all up, I'm learning a bit of PHP...

I'd appriciate it if someone could help me here...
What I'd like to do is add some code to the script which would automatically delete old posts. Let's say the board would only display 20 latest threads (normally the post just go on forever and you have to manually delete them ). The threads are stored in Unordered Lists, as you can se in the code (you can find the link to the complete code below).

The post are posted with the date, while the number of posts is being written in 'noposts.txt'... Again, you can see that from the code as it is commented.
If you need more info, just ask.

The complete PHP code from post.php is here, I'd really be grateful if you could take a peek -> http://www.pastebin.com/91794

Thanks in advance!
daiv is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-13-2004, 02:24 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
When I clicked the link I didn't see any code
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 08-14-2004, 05:25 AM
Novice Talker

Posts: 6
Trades: 0
Seems like Pastebin deleted it already... I've renamed post.php to post.txt, so you can view it. Here it is - http://rum.f2o.org/temp/post.txt
daiv is offline
Reply With Quote
View Public Profile
 
Old 08-14-2004, 09:56 AM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
Is it possible for you to add a unix timestamp to your posts?

Or you have to get the auto remove to work with the date you aleady have present.
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 08-14-2004, 10:13 AM
Novice Talker

Posts: 6
Trades: 0
Unix timestamp? I don't know what that is, but if it is of any help, my server is on Unix OS.

If you have an idea how to auto delete with the date set up how it's set up right now, I'd appriciate your help... But anything that works is fine with me, of course
daiv is offline
Reply With Quote
View Public Profile
 
Old 08-14-2004, 09:55 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
How does the date look in the file?

Like is it setup like: 8/19/2004

What kind of format does it loook like after you post it into the script?
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 08-15-2004, 05:10 AM
Novice Talker

Posts: 6
Trades: 0
After the post is cast, this is the date next to the post on index.php, and also below the actual post (after you click on the post) ->

Nick - Sunday, August 15. - 9:00
daiv is offline
Reply With Quote
View Public Profile
 
Old 08-15-2004, 04:23 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
Well that would be hard to removed based on that time format. In my opinion anyways. SO, I suggest using the timestamp. The timestamp is the date and time of the post writin in one long variable.

To get the timestamp you use:
$timestamp=time();

Then to check it you would do this:

$timestamp=time();
$timestamp2=Post time //However you want to pull it
$checktime=$timestamp-$timestamp2;
if($checktime<86400){
//REMOVE
}else{
//NO REMOVE
}

86400 = 24 hours in seconds.

Hope that helps.
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 08-16-2004, 06:20 AM
Novice Talker

Posts: 6
Trades: 0
Hm, '$timestamp2' is the time when the post was cast? What do you suggest I use for that?
So, this code would remove all post more than one day old?
Which piece of code actually deletes the posts (or you left that out?)?
daiv is offline
Reply With Quote
View Public Profile
 
Old 08-16-2004, 11:28 AM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
Hey daiv,
Sorry I did't explain very well. Okay.

When a user posts add to the database (or index) that is holding all of the posts the unix timestamp.

The timestamp is accessible by using: time()
$timestamp=time();
echo $timestamp

Then in your auto delete script. You would pull ALL of the posts. (However you want to do that) and check the timestamp value.

same as you would try to check the DATE that you showed me erlier.

To check the timestamp you would do this:
$timestamp=time(); //This gives the timestamp for right now.
$timestamp2=Post time //The Posts Timestamp
$checktime=$timestamp-$timestamp2; // Minusing the two.
if($checktime<86400){ //Checking to see if its been 24 hours.
//It has no been 24 hours. DO NOT REMOVE
}else{
//It has been 24 hours. REMOVE POST.
}

However you want to remove the post is up to you.

Hope that helps
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 08-16-2004, 12:49 PM
Novice Talker

Posts: 6
Trades: 0
Ah, I see... I'll try to implement this... Thank you for the help, I appriciate it. Cheers.
daiv is offline
Reply With Quote
View Public Profile
 
Old 08-16-2004, 12:54 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
Anytime, Good luck!
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Reply     « Reply to A bit of help with a simple threaded PHP board needed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32734 seconds with 12 queries