Re: select text from a text file
| From: | Bastien Koert | Date: | Fri, 07 Jan 2005 17:22:56 +0000 |
| Subject: | Re: select text from a text file | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38072@lists.php.net to get a copy of this message | ||
read then write, 2 transactions, the second can take place while the user is reading the content
bastien
From: "Ed" <ed@legend.co.uk> To: "Bastien Koert" <bastien_k@hotmail.com>,<andrew.kreps@gmail.com> CC: <php-db@lists.php.net> Subject: Re: [PHP-DB] select text from a text file Date: Fri, 7 Jan 2005 15:46:38 -0000 Hi, I've been looking at ways todo this, and as yet haven't figured out howto pull something from the database plus at the sametime update the record, can someone tell me how this is done or where i could learn? i've looked all over phpbuilder and a few other php forums but can't seem to find the answer. Ed ----- Original Message ----- From: "Bastien Koert" <bastien_k@hotmail.com> To: <ed@legend.co.uk>; <andrew.kreps@gmail.com> Cc: <php-db@lists.php.net> Sent: Friday, January 07, 2005 2:06 PM Subject: Re: [PHP-DB] select text from a text file 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 bastienFrom: "Ed" <ed@legend.co.uk> To: "Andrew Kreps" <andrew.kreps@gmail.com> CC: <php-db@lists.php.net> Subject: Re: [PHP-DB] select text from a text file Date: Fri, 7 Jan 2005 08:58:18 -0000 Hi, 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? Ed ----- Original Message ----- From: "Andrew Kreps" <andrew.kreps@gmail.com> To: "Ed" <ed@legend.co.uk>; <php-db@lists.php.net> Sent: Thursday, January 06, 2005 6:55 PM Subject: Re: [PHP-DB] select text from a text filelooksOn Wed, 5 Jan 2005 11:58:59 -0000, Ed <ed@legend.co.uk> 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 itlike this:framepress update it pulls the message from the text file and displays it in thenickname||color||what the user is saying||user how can i make it so that if they have a private message when theybut also deletes the text?variable,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 acanand 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 youwhichoverwrite the private message file with the array you've stored,fast-pacedis all of the current private messages minus the one you're about to display. Please note, this does not scale at all, especially in thetheworld 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 selectword "everybody" it goes to a file called messages.txt and if theyselect"user" or "user2" or "user3" from the list it writes to private.txt isthisat all possible? user and user2 etc arent hardcoded it's pulling thenamesfrom a list of online users.messages.txt,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 tousernameand if it's not 'everybody', write it to private.txt with thethat was selected from the dropdown as part of the row. Does that answer your question? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php