simple, add a 'read flag' column to the table, when the record is viewed, activate this flag (say 0 for unread and 1 for read) (Note: read is a mysql keyword don't use that for a column name) and then only show the ones unread


To: "Andrew Kreps" <[EMAIL PROTECTED]>
CC: <>
Subject: Re: [PHP-DB] select text from a text file
Date: Fri, 7 Jan 2005 08:58:18 -0000


Thanks for answering the question.

I'm going to make it write to a database rather than text file after
searching google and coming accross common problems with text files.

I've now just got to figure out how to mark the message as read in the
database so it does not re-appear next time the user clicks update.

I'm going to build a function that will put the message in the correct table
using an if clause, is that the best method?

----- Original Message -----
From: "Andrew Kreps" <[EMAIL PROTECTED]>
To: "Ed" <[EMAIL PROTECTED]>; <>
Sent: Thursday, January 06, 2005 6:55 PM
Subject: Re: [PHP-DB] select text from a text file

> On Wed, 5 Jan 2005 11:58:59 -0000, Ed <[EMAIL PROTECTED]> wrote:
> > Happy new year folks!
> >
> > The titlemight make this seem like an easy to answer question
> >
> > However here's the complicated bit (well for me anyway).
> >
> > In my text file that is written to by the users in a chatroom it looks
like this:
> >
> > nickname||color||what the user is saying||user
> >
> > how can i make it so that if they have a private message when they press
update it pulls the message from the text file and displays it in the frame
but also deletes the text?
> >
> You should be using a database for this, it makes things so much
> easier. That being said, here's one way to go about the text file
> version:
> Open the file, read through it line by line.
> As you read it, push the lines into an array.
> If you find a private message for the user, store that in a variable,
> and do not push it into the array.
> Finish reading the file.
> If there's a private message, you've got it in a variable, and you can
> overwrite the private message file with the array you've stored, which
> is all of the current private messages minus the one you're about to
> display.
> Please note, this does not scale at all, especially in the fast-paced
> world of chat rooms. You will likely end up with file locking
> problems if you proceed with the flat-file method.
> > Also, how can i make it so that if in a drop down menu they select the
word "everybody" it goes to a file called messages.txt and if they select
"user" or "user2" or "user3" from the list it writes to private.txt is this
at all possible? user and user2 etc arent hardcoded it's pulling the names
from a list of online users.
> >
> Are you talking about appending messages to a text file? In that
> case, you can have the dropdown submit with the message, and in the
> PHP code have a case for 'everybody' where it writes to messages.txt,
> and if it's not 'everybody', write it to private.txt with the username
> that was selected from the dropdown as part of the row.
> Does that answer your question?
> --
> PHP Database Mailing List (
> To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

-- PHP Database Mailing List ( To unsubscribe, visit:

Reply via email to