#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    How can I cath the first line of a .txt file or whatever in PHP, using include("") ?

    I need it for this, like, I'm thinking of doing a site with reviews on it, and I want to have one .php file for all the reviews. So that I can open a review using review.php?review_id=photoshop6

    Im planning to have each review as one txt file, that I write "by hand" with the first line as the title. (If anyone knows of a better, smarter and faster way to do this, let me know, i'm new with PHP. With MySQL or whatever.)

    The script should first parse the first line of the .txt file and use that one for title, so i can use a different size of text for it, and then it should parse the rest of the file and use for body text.

    Please help me with this.

    ------------------
    Johan SahlÚn
    www.cerberodesign.net
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I'm not sure what you mean, but maybe this is what you want :

    $finput=file($review_id.".txt");
    for($i=0;$i<count($finput);$i++) {
    echo stripslashes($finput)."<BR>";
    }
  4. #3
  5. Wiking
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    3,608
    Rep Power
    27
    I'd stick to PHP and MySQL instead, as I think it is easier to maintain and faster than using filereading. Create MySQL-table(s) that stores all your info and let PHP read from them. The table-layout depends on what you want to do (how many tables, what content etc), but as a small example:

    Table: Reviews
    +----+-----------+----------+
    | id | program | review |
    +----+-----------+----------+
    | 1 | photoshop | blahblah |
    | 2 | gimp | whatever |
    | 3 | bruce | and so on|
    +----+-----------+----------+

    In your PHP-file you read from this table and can then format your title different from the contents of the review. You can also show only the first 100 characters from the review-field on page one, and then use the id as a link to next page where you show the whole reviewtext.

    That's how I would approach it, but the choice is yours...

    / NoXcuz
  6. #4
  7. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    hi
    try this

    $filename = "yourfilename.txt";


    $hits = file($filename); // The file is in an array
    $totaal = count($hits); //the nr of lines in $hits!

    for($i=0 ; $i < $totaal+1 ; $i++)
    {
    $line = $hits[$i]; //
    echo "$line[$i]";
    }

    This must show every line in the txt file

    ------------------
    Quote the Dokus:"NeverMore!"

Similar Threads

  1. help with tables and wordwrapping
    By junkedBrian613 in forum PHP Development
    Replies: 2
    Last Post: February 15th, 2004, 06:42 PM
  2. Help with parsing a text line
    By larryjoe in forum Visual Basic Programming
    Replies: 6
    Last Post: February 10th, 2004, 05:12 PM
  3. How to read multiple line text file into a variable
    By gatewaycityca in forum Visual Basic Programming
    Replies: 4
    Last Post: January 29th, 2004, 01:26 PM
  4. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 07:19 PM
  5. float question
    By yeah-yeah in forum HTML Programming
    Replies: 10
    Last Post: January 15th, 2004, 04:59 PM

IMN logo majestic logo threadwatch logo seochat tools logo