Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'identify record in text files'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello Larry, Thank you for your book that had helped me effectively changed my html website into php site - it's really clear and easy to learn from your book! I am now reaching the "Files and Directories" section (Chapter 11, page 297) and have gone through the chapter already. I was trying to write some code but was stuck here. I did some research on the web but still cannot make it. Could you please help? What I have been trying to do is to write a php script to do the following: 1) read the "First name" (or a unique "username") from the calling URL (using POST or GET), 2) then check the records in the text file to see if there is a match, 3) if there is a match, print the full name, company name and introduction of that record. I am enclosing a text file and my php script below for your review. The text file contains three lines (records), each line has the First name, Last name, Company name, Introduction. My script so far can only display all the elements of the file. I don't know how to pick only one record (line) from the file, then print elements of that record only. My question is: How could I identify a record in a text file (database), then print the selected values of that record only? I am not using a database program at this point. Thanks, Cofa Tsui New to the forum 9/4/2011 TEXT FILE 3 LINES ONLY "00_test_readtextfile_records.txt" ========================================= Peter##KWAN##First Street Company##This is my introduction. Please send me your comments. Thanks! Mary##THOMSON##Johnson High School##I am a grade 3 teacher here. I love facing the kids everyday! Billy##YU##Billy Travel Agency##We specialize in cruise ship tours in the Caribbean - Let me know when you'd like to have your vacation! PHP SCRIPT "00_test_readtextfile1.php" ========================================= <pre> <p>1ST PART - PRINT ALL LINES IN FILE ("config2" as array):</p> <?php $file = "00_test_readtextfile_records.txt"; $config = array(); $config1 = file_get_contents($file); $config2 = explode("\n",$config1); print_r($config2); ?> </pre> <br><br> <pre> <p>2ND PART - PRINT ELEMENTS OF INDIVIDUAL LINES</p> <?php $num; foreach ($config2 as $i) { $num++; } for ($i=0;$i<=$num-1;$i++) { $config3 = explode("##",$config2[$i]); print_r($config3); } ?> </pre>
×
×
  • Create New...