Reply
Flat File Database Idea... No Knowledge On How To Do It Though...
Old 10-16-2009, 09:40 PM Flat File Database Idea... No Knowledge On How To Do It Though...
Physicsguy's Avatar
Extreme Talker

Posts: 186
Name: Physicsguy
Location: On Earth
Trades: 0
Hey all,

I'm sure some of you know about my flat file database troubles, and you've all said "Use SQL!". I know. I don't really want to. I want to try this, so if you're just going to post "Use SQL!", I di'nt really want to hear it

Now that that's done with, here's my question:

How can I turn this English to PHP?

Code:
Open database
Make it a variable 
look for the line that starts with a given number (a serial number, coming from a variable)
write everything in the database from that serial number...
 ...until you hit the delimiter
display that (the part from the given serial number (it could be 200 lines in) to the next delimiter (from that serial number)
So I really need to just place the file pointer at the serial number, somehow, then echo everything from there to the page until you hit the delimiter. For example:

DATABASE:

12345 CONTENT
CONTENT
CONTENT
CONTENT CONTENT
CONTENT CONTENT CONTENT
CONTENT
CONTENT |

54321 CONTENT 2
CONTENT 2
CONTENT 2
CONTENT 2 CONTENT 2
CONTENT 2 CONTENT 2 CONTENT 2
CONTENT 2
CONTENT 2 CONTENT 2
CONTENT 2
CONTENT 2 |

62648
CONTENT 3
CONTENT 3
CONTENT 3CONTENT 3
CONTENT 3CONTENT 3CONTENT 3
CONTENT 3CONTENT 3
CONTENT 3CONTENT 3CONTENT 3CONTENT 3CONTENT 3CONTENT 3
CONTENT 3CONTENT 3CONTENT 3
CONTENT 3CONTENT 3
CONTENT 3CONTENT 3
CONTENT 3CONTENT 3CONTENT 3CONTENT 3

CONTENT 3
CONTENT 3CONTENT 3

CONTENT 3CONTENT 3
CONTENT 3
CONTENT 3CONTENT 3

CONTENT 3

CONTENT 3
|

73251
CONTENT 4
CONTENT 4CONTENT 4CONTENT 4
CONTENT 4CONTENT 4
CONTENT 4
CONTENT 4
CONTENT 4
CONTENT 4

CONTENT 4CONTENT 4CONTENT 4
CONTENT 4CONTENT 4
CONTENT 4CONTENT 4CONTENT 4
CONTENT 4CONTENT 4CONTENT 4CONTENT 4
CONTENT 4CONTENT 4CONTENT 4
CONTENT 4CONTENT 4
CONTENT 4 CONTENT 4 |



PAGE:


READ FROM "62648" to nearest "|" (What I want, in English)

Would output the block of CONTENT 3s. (The red part)

How would I do this? Thanks!

If I'm not clear, I'll post more, but I don't know...

Last edited by Physicsguy; 10-16-2009 at 09:42 PM.. Reason: More Details
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
 
When You Register, These Ads Go Away!
Old 10-17-2009, 09:24 AM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
chrishirst's Avatar
Super Moderator

Posts: 22,225
Location: Blackpool. UK
Trades: 0
read the file into a string split the string into an array.

then display the element that contains the search string.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-17-2009, 10:04 AM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
Physicsguy's Avatar
Extreme Talker

Posts: 186
Name: Physicsguy
Location: On Earth
Trades: 0
Looking at that page, I noticed a function called stream_get_line. It reads everything from the beginning of a file to a given delimiter.

I can't figure out how to use this.

I need to make the script read from a point in the database (find serial number) and display everything from there to the nearest delimiter (stream_get_line).

stream_get_line makes it much simpler, but I still am in the dark here.

I'd even appreciate a small code snippet that would sort of work! Thanks!


Chris, I don't know how to do that. Sorry I tried, and failed. It froze my whole browser because what I made came up with a few hundred errors!
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 10-17-2009, 08:00 PM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I think chrishirst meant for you to read the whole content into a string first, then split it and find the piece you want.
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-18-2009, 09:58 AM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
Physicsguy's Avatar
Extreme Talker

Posts: 186
Name: Physicsguy
Location: On Earth
Trades: 0
Yeah, I know. What I don't know is how to do that. I've looked at split, but it says it's deprecated. Could I use explode instead?
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Reply     « Reply to Flat File Database Idea... No Knowledge On How To Do It Though...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11951 seconds with 13 queries