RK, this is ultra-basic stuff.  Opening and dealing with files is one of the
first things you learn with any language.  I would highly recommend buying a
beginners guide to PHP book and learning thist stuff on your own.  But for
now this will get you started...

//Open a file into an array..
$rows = file('table.txt');

//Separate each row into fields..
for ($i=0; $i<count($rows); $i++)
 $table[] = explode(',', $rows[$i]);

//Print table..
echo "<table border=2>\n";
for ($i=0; $i<count($table); $i++)
 echo "<tr>\n";
 for ($j=0; $j<count($table[$i]);$j++)
  echo "<td>".$table[$i][$j]."</td>\n";
 echo "</tr>\n";
echo "</table>";

Good luck.


----- Original Message -----
Sent: Tuesday, September 10, 2002 11:29 AM
Subject: [PHP] Strore Data in File

> Hi
> I want to store the data of a table in a file and read that file
> just as one would read a table. For e.g. I have a table t_data
> with cols name,number,cost and my data file data.txt would have
> the following data:
> -------
> john,1,100
> mark,2,200
> spencer,3,200
> -------
> Now on the web page when the visitor clicks on a link on "john"
> then this file (data.txt) must be read and the data should be
> displayed for "john" i.e.
> name = john
> number = 1
> cost = 100
> must be displayed
> Can anyone please give me the code to parse this file and read the
> data for john and get all the data for that row. Please see that
> "john" functions as the primary key in the table
> Regards
> Ram
> __________________________________________________________
> Give your Company an email address like
> ravi @ ravi-exports.com.  Sign up for Rediffmail Pro today!
> Know more. http://www.rediffmailpro.com/signup/
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to