Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: PHP File Manipulation Viewing data from a file Tutorial

Learn how to retrieve and view data from a flat file database (text document) once it is written.

Tutorial Details:

PHP Tutorials
Before reading this tutorial, if you haven't already done so, it would be a good idea to read the writing to a file tutorial , as this one is basically a follow-on from it.
As always, start with the Now we define the file we are going to get the data from.
$file = file("data.db");
Next, we flip the data in the file around, so the latest addition to the file is displayed first, using the array_reverse() function :)
$file = array_reverse($file);
Then we use a foreach() loop to take the data from out data.db file, identify it and display each entry.
foreach($file as $key => $val) {
echo "$val";
}
Finally, end the code up with the ?> thingie.
?>
As I always do for the lazy ones out there, here is the complete code.
$file = file("data.db");
$file = array_reverse($file);
foreach($file as $key => $val) {
echo "$val";
}
?>


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
PHP File Manipulation Viewing data from a file Tutorial

View Tutorial:
PHP File Manipulation Viewing data from a file Tutorial

Related Tutorials:

Use a RandomAccessFile to building a low-level database - JavaWorld January 1999
Use a RandomAccessFile to building a low-level database - JavaWorld January 1999
 
Device programming with MIDP, Part 2 - JavaWorld March 2001
Device programming with MIDP, Part 2 - JavaWorld March 2001
 
Create your own type 3 JDBC driver, Part 3
Create your own type 3 JDBC driver, Part 3
 
Navigate through virtual worlds using Java 3D
Navigate through virtual worlds using Java 3D
 
XML DOM-lite parser and writer
Summary This article provides a simple method for creating valid XML and a simple DOM-like (Document Object Model) parser. This method is useful for small applications that need simple XML functionality without the size and complexity of the full range d
 
The JDBC RowSet Implementations Tutorial
In "The JDBC RowSet Implementations Tutorial," you will look at how to use the standard JDBC RowSet implementations specified in JSR-114.
 
FreeMarker FreeMarker 2.3.1 an open-source HTML template engine.
FreeMarker provides an easy way to get data from Java servlets into Web pages, and helps you keep graphic design separate from application logic. To use it, you encapsulate HTML in templates.
 
JSP Tutorial
Adding dynamic content via expressionsAs we saw in the previous section, any HTML file can be turned into a JSP file by changing its extension to .jsp. Of course, what makes JSP useful is the ability to embed Java. Put the following text in a file wit
 
Calling JavaBeans from a JSP Page
We will be using this SimpleBean class in this tutorial, so if you haven't read above article then I suggest you do it now.
 
Backing Up and Restoring A MySQL Database
Backing Up and Restoring A MySQL Database Backing Up and Restoring A MySQL Database This tutorial explains the how to backup and restore the MySQL Database. Databases are used to store large amount of precious data and it becomes very important to
 
Developing Distributed application using Enterprise Java Beans, J2EE Architecture, EJB Tutorial, WebLogic Tutorial.
Developing Distributed application using Enterprise Java Beans, J2EE Architecture, EJB Tutorial, WebLogic Tutorial. Distributed Architecture Two-tier application: In the past two-tier applications were used. Two-tier applications are also know as
 
10 Minutes Guide to Ant
10 Minutes Guide to Ant 10 Minutes Guide to Ant Previous Tutorial Index Next Introduction Well for the next 10 minutes get ready to devote to the ant guide. This will make some sence to the ant. Ant is a free tool under GNU Licence and is
 
Building Web Application With Ant and Deploying on Jboss 3.0
Building Web Application With Ant and Deploying on Jboss 3.0 Building Web Application With Ant and Deploying on Jboss 3.0 Previous Tutorial Index Next In this lesson I will show you how to build you web application and install on the Jboss 3.0
 
developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0
developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0 Writing Calculator Session Bean and Calling through JSP Previous Tutorial Index Next In this lesson I will show you how to develop a Calculator Stateless Session
 
Introduction to the JSP Java Server Pages
Introduction to the JSP Java Server Pages Welcome to JSP Section Introduction To JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database
 
Buy Peanut 9.6 Linux in India from us. Peanut 9.6 distribution is available in India.
Buy Peanut 9.6 Linux in India from us. Peanut 9.6 distribution is available in India. Peanut 9.6 Linux Now Available Peanut 9.6 Linux CD It is a Linux OS (operating system), especially made for those new to Linux. This is the most POWERFUL and
 
Struts Guide
Struts Guide Struts Guide This tutorial is extensive guide to the Struts Framework. In this tutorial you will learn how to develop robust application using Jakarta Struts Framework. This tutorial assumes that the reader is familiar with the web
 
What is Web Hosting
What is Web Hosting What is Web Hosting? What is Web Hosting? If you have a company and want web presence than you need a website. With the website any one from the world must be able to view your pages, images etc. Website is actually a
 
Running JavaServer Faces Technology-Based Portlets on Sun Java System Portal Server 6 2005Q1
You can extend the framework based on JavaServer Faces technology and then run a JSR 168-compliant portlet on Sun Java System Portal Server 6. This article describes the setup procedures, offers sample code, and summarizes the known issues.
 
VolatileBufferedToolkitImage Strategies
Ever wondered what kind of image to use in your application? Or what method to use in creating it? This article attempts to address this challenging topic.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.