On 1/30/2006, "globalsoho6" <[EMAIL PROTECTED]> wrote:
>
>i'm really a newbie to php but not OOP.
>
>i'm designing a database to hold simple text messages to display in a
>page called, "News". The client doesn't want a sql database so I
>suggested a plain text database. I have it working but when I pull the
>data (fopen) it all comes back as one line.
>It's set up as a simple form passing 2 variable, $title and $comments.
>They both write (fwrite) just fine to the .txt file but upon
>retreiving them (fopen) it's all one line. Since I can't pass formated
>text to a .txt file is there a different way?
>As a newbie I haven't come across a solution yet. The client wants
>this soon so I'm asking here due to the timeline. Given a few more
>weeks I'm sure I'd stumble across it in some text.
>
>Thank you!
>dan
>dan burfield design.com
>
Hi Dan, welcome!
I'm sure there are many ways to do this. In my case, the fields in my
data base are separated by the "pipe" symbol - "|". I can open my
data base file and see that each record is on its own line (that is,
each line ends in a line feed).
I use the following code to process record-by-record:
$lines = file('data/data.edit1.txt');
$i = 0;
foreach ($lines as $value1)
{
$lineData = explode('|', $value1);
// exclude any commented lines
if (substr( $lineData[0], 0, 1 ) !== '#')
{
$date = trim( $lineData[0] );
$event = trim( $lineData[1] );
$link = trim( $lineData[2] );
. . .
Hope that helps,
Mike
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/