Flat File Display <i>x</i> Number Of Lines
I have a "site updates" script that I wrote that stores my site updates in a flat file in the form:
21234123|>|blah blah blah
21234123|>|blah blah blah
21234123|>|blah blah blah
where 21234123 is a unix timestamp.
what I want, is to be able to display the last x updates on my main page. I have a "updates.php" page which displays ALL updates... but I want to display just the say... most recent 3 or 5 updates at the bottom of my main page.
This is my function that displays -all- updates.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Deleting Lines From Flat File
I am trying to display all the news items in my flat file with 'delete' links (<a href="managedeletenews.php?action=delete&id=$key">Delete[/url]) that call the same page to strip out the line and rewrite the file. However, when the delete link is clicked nothing happens (except the page's address changing from "managedeletenews.php" to the above. Am I using the references to the $id or $key variables incorrectly? Is it something to do with the undefined $action variable? Or is it something else?? BTW, the embedded styles for the delete link - shown below - don't seem to be throwing up any errors. Code:
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,
How To Limit Output Lines Per Page Using A Flat Txt Database
I searched the boards for some direction in limiting the output to so many lines like "Back 1 2 3 Next". However, everything is pointing to mysql databases. Has any one did it with a flat text file? This is a sample of how I print to the screen How can I modify this? PHP Code:
Number Of Lines
Is there a function that returns the number of lines in a text file? If so, what is it?
How To Number 42 Lines 1-14
I have 3 sonnets (14-line poems, fyi) in a file without blank lines and I want to tack line numbers onto the end of each line so that the first 14 lines will be numbered 1-14, as will the second 14 lines and the third. I've exploded the file by " " so that I have each line as an array value. I've been using various loop fuinctions (for, foreach, while) to try to put individual numbers at the end of each corresponding line, but something either loops too much or not at all. This is just an example. I know I could number 42 lines by hand, but I'd like an automated system to do it for much more line numbers.
Checking For Number Of Lines?
I have a problem. I have a static table cell (static meaning that it's dimensions do not change per amount of data) and i want to put news there. Via a mysql database i am outputting the news into this cell, but i want it to only allow enough so that it fits. Is there a way I can see how many lines a string has, or is there some other way to do this?
Display First 4 Lines Of An Article
I am a php newbee and I am building a CMS which stores articles in a database. I know how to display the whole article but what I want to do is to get an article from the database and display the first 4 lines of that article with a link for readers to read the whole article. so I was wondering is there anyway way to do this.
Insert New Row In Table After 5 Lines - Detect Whole Number?
I have a script that loops through an image directory to create a table of thumbnails. I want to start a new row after every fifth thumbnail. I assumed there was a function which identified whole numbers, but alas, there doesn't seem to be. How do I produce a short version of my long, working version below. PHP Code:
Limit Result By Number Of Lines Or Characters?
I'd like to display just the first paragraph or so of text held in a mysql result followed by a link to the full article. Is this most easily done by putting some sort of limit into the mysql query, or is there a php function or method that will cut off the specific result field after so many lines or characters?
How To Limit Number Of Lines Displayed On The Page?
I just wrote this script to read information from a TXT file that contains list of JPEG files, and the list is rather huge. So I want to limit the number of displayed files to like 20 per page (with NEXT/PREVIOUS links to the next or previous 20), but I have no clue how to do it. Code:
Limit String To Specific Number Of Lines
I was wondering how I would go about setting the number of lines for a string. For instance, if I have: This Is Just A Test Say I just have room for 3 lines, I want it to say on the page: This Is Just - click here to read the entire string The reason for this is I want to create a news section on the main page, that has the brief story and then click the link to go to the full story.
Exporting DB Results (or Flat File) To An Excel File
I have two scripts, neither of which have been written, that will need to collect user information. They will either write to a flat file or to a MySQL DB, and I need a way for an administrator to grab an Excel file based on this data. First, no more than 100 people are expected to sign up, so flat file is certainly viable. Do you recommend I use DB or flat file? Second, based on your recommendation, how should I go about exporting the user data to an Excel file? There will be about ten form fields per registration to give you an idea.
Flat File
I run a website for a small (very small) AM radio station. I need to add a page where listener's (all seven of them) can list items for sale. (This will be the online version of a daily call-in "For Sale" show that the station runs.) The station owner wants the listings to disappear automatically after 3 days. My current plan is to let the visitor enter info on a form: telephone no. and item description. The form will tack on a timestamp and then append the data to the target file. When displaying the data, I need to: 1. Only display data less than 3 days old and... 2. Delete from the file data more than 3 days old. I'm thinking of having the display page read the file into an array and compare timestamps to a standard. Those that pass are copied into a temporary file. When the entire array has been checked, the temp file is written over the original target file. The temp file is discarded and the new, most current version of the target file is displayed on screen. Does this seem like a reasonably logical way to do this? I looked at the PHP manual and didn't see a command that removes single entries from a flat file, so this is the approach I came up with. But perhaps I missed something? I'm using a flat file because I don't anticipate ever having more than just a handful of entries at a time. (I also just want the practice with flat files; I haven't used them as much as I have relational databases.) A couple of other notes: Users will not have to have a password or anything like that. They'll just post and the item will stay on the board for three days, as per the station owner's wishes. The system is being kept simple in part because the owner believes that most of the listeners are elderly and (in his estimation) not super computer types.
Flat File
I know this is a total noob question but im just getting into flat file scripts because a friend of mine has a site that does not have a database. so i told him ill try making him a news script made with flatfile so he doesn't have to switch hosts.. but my question is.. is there a way to delete data thats in flatfile? like set them in an array or something?
Counting In A Flat File
Has anybody an idea, how I can count especially some records (e.g. different category) in a flat file? My script only counts the complete lines of the file ... $count = 15; $content = file($conf[myDataFile]); $size = count($content); ... I want to count each recorset that has the same value (e.g. category) like the querystring ($cat) Therefore I have to define the number of the field in the flat file. ... ($myLINES[$i][13]==$cat); ...
Flat File Web Stats In PHP
I'm looking for a basic web stats script that will allow me to count hits, time and where user goes, as well as browser and OS if possible.. I want to be able to customize it into my template... anybody know of something prewritten that i can customize?
New Line On The Flat File
i recently decided to code an extreamly simple php cms which i can use on any websites i make. so far i have made an input form, a procesing page, a flat file, and an index with an explode function which shows the last 5 posts newest to oldest. all of it works up to a point. the problem i have come accross is that when you fill in the message part of the form if you press enter to give a new paragraph it creates a new line on the flat file which the script then thinks is a new line of arrays which makes each new paragraph a new post adding it above its proper post. i wonder if its possible to somehow stop the line break in the textarea counting as one in the flatfile.. or even better if i can replace it with a < br> tag so it shows as a new paragraph.
Flat File Database
I'm making a flat file database script right now and I need to know if there's a certain limit of characters that can be reached so that the information is written onto the next line. For example if I had this text file: hello hello hello hello hello hello hello hello hello hello If I kept writing "hello", is there a certain limit where hello will go to the next line? Because I'm storing each set of information on it's own line, I don't want one of them to become too long and go onto the next line and mess up the database.
Flat File Database
I am making a simple content management system that allows the users to change the basic text on the page and insert new Articles. This will mean having a simple database with a table for page content and a table for Articles. This will be a flat file system. I was woundering if this is a bad design and should i create a database with normalised? I will be using php and mysql to grab the information from the database to display it on my web page.
New Line In A Flat File?!?!
Made a simple script that can add, edit, or delete objects in a flat file. To use for news, simple ecom, etc. Created the script and tested in on one server and worked perfect. Just moved it to the actual server it will stay on and for some reason what used to make a new line for a new object just adds an upright looking rectangle looking symbol. Sorry can't copy it here cause it won't show up; will only show up in notepad. Once the symbol is added it will add the new data in the same line is the last object in the flat file. Anyone have any thoughts?!?!?! Code:
Display The Number Of Results
How can I set the classical search engine message? Found ### results. How can I count the returned results and display them in the results page? so now has the Found 5 results or any number that the result contains.
Open File, Put First 5 Lines Into A Variable, Close File...
1) I want to open a file on my server. 2) I want to read only the first 5 lines. 3) Put the first five lines into a variable. 4) Close the file. 5) Display the contents of the variable. I know how to use the fopen() but I have big problems just trying to read the first 5 lines only? I tried many things. I downloaded some search scripts which displayed the <meta> tag only from html pages... What is this guy doing? Well I have a big site and content is added and changed everyday. I have a dynamic page that reads a directory for files and then puts a link (well it includes the file for reading on my php page). That works great! MY PROBLEM is that I want not only a link but a small description below it (basically the first five lines on the file)... See so far: Quote: if (isset ($content)) { include ("files/$content.html"); echo "<p><A HREF="read.php"><b>Back to index</b></A>"; } else { echo "<b>Opening directory, reading files, and listing them as a link</b><p>"; $handle = opendir('./files'); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo eregi_replace (".html", "", "<A HREF="read.php?content=$file">$file</a><p>"); } } closedir($handle); }
Flat File Code Generator
I want to know how I can add breaks between table elements (html code) when it's generated from a flat file (input forms) ? Right now the code appears in one continous string, and I'd like it to be neat and tidy (breaking in the code after </td></tr> and </table>) Is this possible? Here's teh code, to show you what I mean : http://stage.jpauldesign.com/mctl/h.../viewevents.php
PHP Flat File Vs DB For A Small Website
I'm having trouble deciding on whether to go with a flat file or DB driven architecture for a wee personal website. I'd like to be able to update HTML files online and this is my only requirement. Flat Files: advantage: attach some PHP code at the top of each file that allows the file to be opened and edited disadvantage: the files would have to be writeable DB: advantage: more secure disadvantage: allot of overhead Would anyone have any advice? PS: I was originally planning to use a CMS but found that no CMS was customizable enough with little effort for a basic small website - strang eh :)
Delete Flat File Content
Just have a basic notes.txt to which notes are obviously added to. However, i would like a page "delete.php" to have all content within that file deleted, but keep the notes.txt file intact.
DB -> Flat File, Did I Waste My Time?
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 then load the data from that file, if not the data is loaded from the database and then saved to a file. That way I can copy the database without worries about the cached data itself. It all works as expected, but the question is, did I waste my time? How can I do some load test on my server to see what would be better? Database call or flat file read.
Flat File Database System?
I am researching flat file DBs. I know that they are bad, but a client i am working for does not have access to mysql hosting! What i need to do is to have a set of special offers (say about 8 different special offers, each one consisting of 5 fields (title, link, description, image, end date)). Is there a way (either using a php 'random' script or using a flat file or even the explode/implode funcs) to generate a random page to display 2 random special offers?
Replacing A Record In A Flat File
I am trying to replace a single record in a flat file. The file is relatively small and no need for database. I open the file, and save the ftell() value in a variable. I read a record using fgetcsv(), modify the index contents it if/as necessary. I then position the pointer back to the beginning of that record using fseek(value_from_ftell). I build a new string with the required delimiters. Finally I put the record with fputs() (also fails with fwrite()). What the code actually does, is append a NEW record to the end. Can't seem to find out hot to REPLACE the original record with the new data. Code: --------- $fp = fopen('filename'); $filerec = ftell($fp); -->for...next $user = fgetcsv($fp, 999, " "); /* Code here to change as required $user[0-6] */ $outputstr = $user[0]." ".$user[1]." ". etc, etc fseek($filerec); fputs($fp, $outputstr); -->next fclose($fp);
Database Or Flat File Based?
I'm writing a news script, where I can write articles and have them outputted on my homepage. What I'm wondering before I start is; does anyone have any advice whether something like this would be better of stored in a database or flat files? Some articles could be quite long and I just thought they may be better suited stored in a .txt file for instance, but then again it might not make any difference.
Converting Flat File To Database
I have a script that looks in a flat text file for an image and coordinates, then plots them on Google Maps in a DIV tooltip. I want to convert the script to database but need to know how it works in order to do so (mainly when there is 2 or more pictures under the same coordinates it will group them in the same DIV and not loads over lapping each other). Code:
Using A Flat File For Large Queries.
I have 13 rows of information, and instead of storing that little amount of data in the database, I figured I should save some storage and put the information in a flat file instead. Lets say my flat file looks like this: Account type (int) | amount (int)| more info Account type (int) | amount (int)| more info Account type (int) | amount (int)| more info Lets say my database table looks like this and there are about 5,000 rows. UserID Account_type Would it be insane to loop through the flat file for each individual DB entry and find the matching "account type" for that individual user, then add the "amount" field to a row in the DB according to what account type they have? Or would this be a lot easier if I just stored the flat file information in a table in the database?
Displaying Data From A Flat File?
ive got a flatfile database sorted out, all i need now is how to store individual flat files per user and how to paginate that data. Just to make sure i'm doing everything right, i'll post the code below Code:
Flat File And Passing Data
I am currently working on a project whereby users login to my website (which is working) and then using a form add new links/tabs to their navigation bar (which i need help developing). So for instance if the user had 'home/search engines/favourites' as links on their navigation bar and they wanted to add auction sites as a group title they fill out the form which wants the name of the link and the URL it goes to. So far i can make the form send the link name and URL to my flat file database (usertabs.txt) but i also need the form to once submitted automatically insert the users username before the link and URL to make their new link unique to them. So in the flat file the structure will be: username|Link name|URL The usernames etc are stored in a separate .txt file. I have this code so far which is the basis for uploading new links to a users navigation bar. $userid is the variable i want to be associated with the user who is logged on. Code:
Display Number Of DB Results Beside A Link?
For an example, if you look at www.menupages.ie they give you a preview of how many results are found for each link. ie: Ballsbridge Restaurants (52) Blackrock Restaurants (17) Clondalkin Restaurants (18) Clontarf Restaurants (17) How is this achieved. I take it that it must be a select count on the DB for each row but that seems pointless, is there an easy way to achieve this?
Deleting Not Working - Flat File Database
I have to decrypt the $email variable in order to delete from a flat file database. I am not sure how to do this... It decrypts it and trims it to display on a select field, but I don't know how to make it delete. Code:
PHP Flat File Search Engine (a La Lucene)
Wonder if someone could help me. I'm looking for a PHP/MySQL based search engine that can search flat files i.e. build it's own index from flat files. I've used Apaches' Lucene before (http://jakarta.apache.org/lucene/docs/index.html), so I'm looking for something similar. If there's a pay-for product out there, I don'd mind paying. So, it needs: - Ability to search a set of flat files and build an index - Allow users to enter BOOLEAN operators, e.g. dog AND cat OR donkey - Return results on an accuracy match basis e.g. no. of times all words in search phrase occured in a file/record
Reading Flat File Information Into Arrays
1. I have a form that wirtes to a flat text file when it is submitted. The form allows you to input up to 3 stories - each with a headline, date and the body copy. I am writing the information to a flat text file. 2. I want to read this flat file into another page and have it know that the first entry is the headline, the second entry is the date and the third entry is the body copy and do this for as many stories that have been input. I am thinking the best way to do this is to use some sort of loop and an array but don't know how to set this up.
Flat File Database Image Gallery
I don't have a database available, so i'm writing an Image Gallery with a flat file database. I have an Add Page: Uploads Image file, and saves $filename and $caption to text file: captions.txt Captions.txt is in format: photofilename.jpg|caption to do with photo here. I can easily read out each individual part from the captions.txt file to display the photo and caption on a display page. I also have a delete file that unlinks the photo, using the info in the captions.txt file, but i can't figure out how to remove the entire line from the database file based on the filename...??? Basically I want to click on an image like this: <a href=delete.php?filename=phototodelete.jpg> and have the delete.php file unlink the picture, and then erase the line in the text file, that begins with the filename (phototodelete.jpg). I guess i need to search through the data file and when i match the filename, erase the line...
How To Sort A Flat Text File By A Particular Field
I have created a flat file database to store contact information on my friends. The fields are 'firstname', 'surname', 'job title', 'address' etc What I am trying to do is be able to display a sorted list of my friends based on a particular field eg 'sort by surname'or 'sort by address' etc Each row in the file ends with a '' and each field in each row is separated by a ' '. I have come to the conclusion that I need to use the array_multisort function but cannot find any examples of taking information from a flatfile database and using array_multisort to sort and display based on a particular field. This is how far I have got but I am now stuck as to where to go from here? I have read the php manuals but it does not appear to improve my understanding of what needs to be done. Code:
Reading/comparing Vars In A Flat File
I am trying to read info that has been written to a flat file, search for a particular variable, and then compare it to existing ones to make sure there isn't a duplicate entry written to it.Ex. 1. Users fill out a form (including username and password) 2. Upon submission they are taken to another page which displays info they just entered so they can verify. 3. After they okay the info and click, they are taken to page four which emails them and writes the info to a flat file. What I want is a way to be able to iterate through the info written to the file and compare the 'username' that the person picked to existing ones. If there is a duplicate, then force them to choose another. This is what I came up with. I get no errors, but it doesn't work... PHP Code:
Help Debugging Flat File Picture Gallery
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give them a caption, storing the caption and filename in a text file. It's a bit buggy when removing the photos and captions from the file, and also in displaying them on the delete page. you can see it in action at www.4am.com.au/gallery/upload.php - read.php - delete.php. You can download the source at www.patoncreative.com.au/gallery.zip, and I have posted it here below... i would appreciate some help in debugging it.. i'm not the best with the 'foolproofing' of it before putting it into use. UPLOAD.PHP######################################## # <form action="upload.php" method="post" enctype="multipart/form-data"> Select a Photo to Upload:<br> <input type="file" name="filetoupload" size=཮' class='form'><br><br> Enter Photo Caption:<br> <input type="text" name="caption" size=཮' class='form'><br> <input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>"> <br> <input type="Submit" value="Upload File" class='form'> </form> <br><br> <?php /* Description ----------------------------------------------------- The Super Global Variable $_FILES is used in PHP 4.x.x. $_FILES['upload']['size'] ==> Get the Size of the File in Bytes. $_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File. $_FILES['upload']['name'] ==> Returns the Actual Name of the File. $_FILES['upload']['type'] ==> Returns the Type of the File. So if I filetoupload the file 'test.doc', the $_FILES['upload']['name'] would be 'phptut.doc' and $_FILES['upload']['type'] would be 'application/msword'. ---------------------------------------------------------------------*/
Sorting News Alphabetically (flat File)
I need som help sorting news alphabetically. I use the explode function to get the contents. And the while() function. Basically, I explode the "|" sign and I want to be able to sort any "|" row alphabetically. Somebody have a clue ??
|