473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Flat File Database - How to Load and Edit Lines?

I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one
(with, say, a radio button) it will load into the form at the bottom of
the page, where I can edit the fields, and save back to the same line in
the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!
Thanks
matt
Jul 17 '05 #1
6 4268
On 2005-01-26, matt <mc*****@gmail. com> wrote:
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one
(with, say, a radio button) it will load into the form at the bottom of
the page, where I can edit the fields, and save back to the same line in
the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!


Well, you could consider each line to be unique by it's linenumber.

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2
Tim Van Wassenhove wrote:
On 2005-01-26, matt <mc*****@gmail. com> wrote:
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one
(with, say, a radio button) it will load into the form at the bottom of
the page, where I can edit the fields, and save back to the same line in
the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!

Well, you could consider each line to be unique by it's linenumber.

ok, but is it possible to do it all in one page, select from the list,
load it back into the form at the bottom, and then save back over
itself? how do i go about finding the line numbers?
Jul 17 '05 #3
On 2005-01-26, matt <mc*****@gmail. com> wrote:
Tim Van Wassenhove wrote:
On 2005-01-26, matt <mc*****@gmail. com> wrote:
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one
(with, say, a radio button) it will load into the form at the bottom of
the page, where I can edit the fields, and save back to the same line in
the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!

Well, you could consider each line to be unique by it's linenumber.

ok, but is it possible to do it all in one page, select from the list,
load it back into the form at the bottom, and then save back over
itself?


Yes it's possible.

how do i go about finding the line numbers?


Count while you are reading.

or do it like this:

$file = '/tmp/test';

// read file into array
$lines = explode("\n", file_get_conten ts($file));

// output each line with it's linenumber
foreach($lines as $num => $val)
{
$val = htmlentities($v al);
echo "<p><input type='radio' name='line' value='$num'>$v al
</p>";
}

// now manipulate the $lines array
.....

// write array into file - might want to read the manual if you're not
// using php5 for an alternative
file_put_conten ts($file, implode("\n", $lines));


--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #4
matt wrote:
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one (with, say, a radio button) it will load into the form at the bottom of the page, where I can edit the fields, and save back to the same line in the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!


Don't invent your own flat file DB. There are plenty of such works
available.

You may also try PHP way:
1. http://in.php.net/var_export with include()
2. http://in.php.net/serialize and unserialize()

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #5
R. Rajesh Jeba Anbiah wrote:
matt wrote:
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one


(with, say, a radio button) it will load into the form at the bottom


of
the page, where I can edit the fields, and save back to the same line


in
the text file.

I dont know how to use primary keys or anything with a text file
database, any help in this would be appreciated!

Don't invent your own flat file DB. There are plenty of such works
available.

You may also try PHP way:
1. http://in.php.net/var_export with include()
2. http://in.php.net/serialize and unserialize()

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

i already have it adding records, and erasing records, but i just want
to be able to edit records (or lines) and save back over itself...

i've tried to use 1 page to select the line to edit, then send that info
to another page to edit it, but i'm not winning...

Jul 17 '05 #6
Try changing the db format to arrays and serialize it -- which will be
indexed by their numberical keys. Then you open the file, unserialize
it, loop to output the key, and the other info, maybe include a hidden
field with the value of the key, and then when you submit it to edit
it, load the stuff with that key. . .

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1818
by: amorphous999 | last post by:
I want to use DTS to load from a flat file. But I can't be sure when the flat file will arrive. I would like the job to check every 10 minutes or so for a couple of hours. If the file is present, then load the file and rename it so that it doesn't get overwritten. Any suggestions? TIA, amorphous999
4
1714
by: Ben | last post by:
So, at my place of employment, we use a national standard to transmit data between certain applications. This standard consists of a fixed width, flat file 4500-some-odd chars wide that contain 375-some-odd columns (Not delimited). This standard is not changing anytime soon, so I attempting to write a library of some sort to read and write these files within our SQL databases (which use 160 of those columns, but completely ignore the...
3
6484
by: blackd77 | last post by:
What I would LIKE to do is noted in the subject line. What I'm finding is that "edit SQL" appears to only be an option if I am creating a table. If I select "append to" the option to edit SQL shades itself as unavailable. The reason I'd like this is that there is a datum in the flat file that indicates whether that record should be appended to that table noted above. There are other ways of dealing with this "problem" but it would be...
14
2270
by: vunet.us | last post by:
Hi, I would like to use flat file data storage instead of database. Since I am new to it, I am wondering: What text file extension is a safe one to store my data online and how cost- and time-effective is this method (flat file data storage). Anyone can share thoughts? Thanks
9
2185
by: FFMG | last post by:
In my site I have a config table, (MySQL), with about 30 entries; the data is loaded on every single page load. This is not the only call to the db, (we do a total of about 8 calls to the db). As with many configurations settings, once the options are set the values will not change much. So I thought it would be a good idea to move the data to a flat file. I have written a small wrapper class to first look for the file, if it exists...
5
1940
by: deppeler | last post by:
Can someone look at this for me: I am trying to set up a script to edit an item in a flat file DB but I don't seem to be getting the data to the Photoedit script. It seems to be reading the 1st line of the DB and not what is selected. I am all messed up..I know this is straight forward but I am having a real hard time with this. I am wanting the user to be able to select a photo (nfile_name - radio button) and if desired alter the text...
9
1887
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Hello I am developing a system for user tracking. In this I am tracking all the visitors that came to my website. i developed this using a HTTPModule and storing the data in a SQL Server database. Everything worked fine till my website gets good traffic. When website is getting good traffic, this method is slowing down the entire application. So I am planning to use flat files instead of SQL Server database. My doubts are
15
5263
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
3
3165
by: Flugeldorph | last post by:
I am new to Visual Basic, my preferred languages is C or C++. I am trying to load a local database with data that I am reading from a delimited flat file. I have created the database tables and added all primary keys and a set of foreign keys. I have also created a Dataset for same. Now I was expecting that I could load the data set from the data that I am parsing from the flat file. Houever when I attempt to enter data into the dataset I can't...
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.