Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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
404 - Title not found

Latest Blog Post:
Challenges
Posts: 823
Name: Scott
Location: Ontario
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...
__________________
Check out my
Please login or register to view this content. Registration is FREE

Last edited by Physicsguy; 10-16-2009 at 09:42 PM.. Reason: More Details
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-17-2009, 09:24 AM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,516
Name: Chris Hirst
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
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
404 - Title not found

Latest Blog Post:
Challenges
Posts: 823
Name: Scott
Location: Ontario
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!
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 10-17-2009, 08:00 PM Re: Flat File Database Idea... No Knowledge On How To Do It Though...
lizciz's Avatar
Webmaster Talker

Posts: 744
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.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
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
404 - Title not found

Latest Blog Post:
Challenges
Posts: 823
Name: Scott
Location: Ontario
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?
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
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.23653 seconds with 12 queries