Content management with flat text files...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eragon
    Contributor
    • Mar 2007
    • 431

    Content management with flat text files...

    i have a script that will write to a text file from a form... using php scripts.. now i need a script to call from this file line by line, or any similar way of posting it, and insert it into my php home page. i have the script set up and working, it posts a headline on say line 1, a news article on line 2, and line 3 is blank. then when i submit again it posts a headline on line 4, a news article on line 5, and line 6 is blank.

    the txt file looks as so:

    [CODE=text]Heading 1
    THis is the news article asociated with heading 1. it is saved as one line in for example news.txt

    Heading 2
    This is the news for heading 2. it was submitted by for example submit.php and is displayed on index.php in a table.
    [/CODE]

    now i want this to load as so:

    [HTML]<table>
    <tr><th>Headi ng 1</th></tr>
    <tr><td>THis is the news article asociated with heading 1. it is saved as one line in for example news.txt</td></tr>
    <tr><td></td></tr>
    <tr><th>Headi ng 2</th></tr>
    <tr><td>This is the news for heading 2. it was submitted by for example submit.php and is displayed on index.php in a table.</td></tr>
    <tr><td></td></tr>
    </table>[/HTML]

    pretty simple?

    just a few notes: i dont have a working mysql server, if anybody knows a free sql server that i can use that actually works, i need to have a link, otherwise i will stay with text files... help!

    Sincerely,
    Eragon
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    [PHP]
    <?php
    $handle = @fopen("yourFil e.txt", "r");
    if ($handle) {
    while (!feof($handle) ) {
    $buffer = fgets($handle);
    $lines[]=$buffer;
    }
    fclose($handle) ;
    }
    ?>

    [/PHP]
    now you have whole file in array - $lines

    i hope that help

    ps: why you dont yous mysql? i know its hard to set up but you will love it!!!

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      MySQL is free. Unless you mean you need a free server to host the database.

      A-Plus.net's Solo XR plan is at a pretty reasonable rate right now (about $7.50 per month), and you can probably find better deals. $90 per year plus domain (plus ICANN) ain't bad, plus you can host the rest of your site from that server, too.

      My boss once built a 'database' using flat text files. It might be why he says he feels so old all the time (hint: he's NOT old!).

      Comment

      • eragon
        Contributor
        • Mar 2007
        • 431

        #4
        can i just make a database on my computer and upload it as a file, or, does it have to be integrated with the server? i tried using *.mdb files with *.aspx files, but i couldnt get it to work right... i need anything that can help a person (me) who only knows html, javascript, some php, everything about access, lots of dreamweaver, and some japenese... any ideas, btw, how do i call the array in that code above?

        what would the script look like in the news page...

        [PHP]<?PHP
        echo ($lines_1);
        ?>[/PHP]

        or what??

        SIncerely,

        Eragon

        Comment

        • eragon
          Contributor
          • Mar 2007
          • 431

          #5
          and by the way, i need free links, cuz right now alls i have in my company account is -$14, so, ya... I took out a loan from my friend to fix my router cables, geez do i hate my dog...

          it seems to me everything online requires you to pay... i cant even get a decent domain name without putting myself in debt...

          and im still in buisness, imagine that?

          Comment

          • ronnil
            Recognized Expert New Member
            • Jun 2007
            • 134

            #6
            try setting up your own server for testing purposes, you can do that on the machine you're running.

            apache server is free (and great btw), most unix based webservers are apache

            IIS (Internet Information Services) is free if you have windows XP Pro (it's on your install disc)

            php can be downloaded (for free) from php.net, you will also find a complete reference, very well written.

            mysql is also free and can be downloaded from mysql.com

            Everything is supplied with user/installation manuals and should be achievable to setup within a few hours.

            if you want php to work with MS access i think you need a library to do so (this can also be gotten free of charge from somewhere)

            Comment

            • eragon
              Contributor
              • Mar 2007
              • 431

              #7
              cool. i tried aspx with ms access, but the codes dreamweaver gave me dont work... :( ill look into using MySQL, even though i have no experience. is it similar to mdb?

              Comment

              • eragon
                Contributor
                • Mar 2007
                • 431

                #8
                MySQL Database Links / Tutorials Needed

                my question still remains. links to tutorials would be nice. i have decided to use sql, however, i need to know how ot use it. the web host i have has sql. i need tutorials!!!!!! !
                Last edited by eragon; Jun 11 '07, 02:47 AM. Reason: needed to change title

                Comment

                Working...