[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
ClanKiller.com - View topic - another php question
It is currently Sat Nov 23, 2024 2:06 pm



Reply to topic  [ 6 posts ] 
another php question 
Author Message
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16662
Location: On a slope
Reply with quote
Post another php question

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Thu Oct 30, 2003 1:29 pm
Profile WWW
Emperor
User avatar

Joined: Wed Apr 16, 2003 1:25 am
Posts: 2560
Reply with quote
Post 

_________________
++


Sat Nov 01, 2003 2:34 am
Profile WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16662
Location: On a slope
Reply with quote
Post 

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sat Nov 01, 2003 2:12 pm
Profile WWW
Duke
User avatar

Joined: Mon Mar 31, 2003 8:59 am
Posts: 1358
Location: right behind you
Reply with quote
Post 
Don't do .txt files. Don't be a pussy. This is a very easy project to start learning MySQL. Plus, there are tons of things you can do with a database other than search it for a text string.

1. If you store your news in a database then you all you have to do is store the date it was entered as one of the fields in the entries row. Then you can just selectively get the 10 most recent news post, or whatever.

2. There would be no manual movement of files. Archiving, etc would be automatic.

3. files are much harder to work with properly than a database.

4. A database would be much more effecient. Why use programming if you are going to castrate the concept. That's like buying car so you can store your gas in it. If you want to store your gas, get a gas can. If you are using a car, then fucking drive it.

This is a great tutorial to get started with PHP/MySQL:
http://www.sitepoint.com/article/228

So that you have a framework of what you need to do, I will diagram the process below. When you hit a question, ask. BTW, I'm not going to help you do this with txt files. That's just a waste of both of our time.

Use phpmyadmin or other db utility to create a table in your database. The table should have a prefix to distinguish it from any other projects in the same database (such as you found with phpbb). I would use ck_, but it is your choice. You will need a field for the text, id, and date. The table might look like this:
ck_news
=========
ck_news_id (int)
ck_news_post (text)
ck_news_date (varchar)

everything should be obvious, but make sure that when you are populating the ck_news_date field, that you use a unix timestamp
Put a bunch of crap in there to test it as well.

When you build the page that you want to have the news, it would be easiest to just create a news.php file and include it on your main page, rather than do the programming on the main page itself (btw, includes, and mulitple includes are no problem - include 100's if you want).

On news.php, connect to the database (see the tutorial above). Then you need to create a simple query like:
$result = mysql_query("SELECT * FROM ck_news ORDER BY ck_news_date DESC LIMIT 0,10");
maybe that should be 1,10... don't recall off the top of my head. You'll figure it out.

The result is nothing more than a mathematical place holder of the results found in your query. There is no data directly accessible from it. You need to create a loop to manually extract the rows from it.
Then you need to get the data from the query:
while( $row = mysql_fetch_array($result) )
{
echo("posted on: " . date("Y.m.d H:i", $row[ck_news_date]) . "<br><br>$row[post]");
}

Boom! done. If you want to see all of them, just don't specify a limit.

I gotta go, ask more questions as they come, or post if I wasn't clear. If you find me online (IM'ing) then I'll explain in excruciating detail what you are actually doing).


Sat Nov 01, 2003 2:32 pm
Profile YIM WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16662
Location: On a slope
Reply with quote
Post 
Thanks Pig. I completely understand what you're talking about... I got a lengthy exhortation on the advantages of MySQL from a PHP friend I have.

In fact, I plan on eventually doing it as a MySQL table. My main reason for going with flat text files was just to learn how it would be done and get a better handle on staight PHP. Once I have all that working, I'll probably just rewrite it all to use MySQL instead.

In fact, I'm basically done with the flat text thing. The only thing I'm working on right now is setting a variable that displays either the first 10 posts (default) or all but the first 10 (when you click the 'older news' button).

When I get to the point of sticking it into MySQL, I'll probably write a .htaccess protected form to automate inserting new news entries.

Oh, and for the record, my news page is index2.html, which is basically

some header stuff like title
include header
include news.txt
include footer

news.txt is where all the actual processing goes on. :) I'm making this sucker so modular I can do anything with it without having to rebuild it from scratch. At least, that's the plan. I'll let you know if I have any more questions.

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sat Nov 01, 2003 7:28 pm
Profile WWW
Emperor
User avatar

Joined: Wed Apr 16, 2003 1:25 am
Posts: 2560
Reply with quote
Post 

_________________
++


Mon Nov 03, 2003 2:46 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.