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
Searching a text file (PHP)
Old 08-23-2004, 02:17 PM Searching a text file (PHP)
Junior Talker

Posts: 4
Trades: 0
I would like to build a script for a restaurant menu, to show daily specials.

for example:

www.restaurant.com/menu.php?day=monday

would search a text file for the specials that are served on monday.
What is the best way of approaching this? I am a complete php newbie, and the script I have written so far doesn't seem to work.

Any suggestions?
Thanks
Choaderboy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-23-2004, 02:54 PM
j0e
Average Talker

Posts: 23
Location: UK
Trades: 0
Not really sure why you would want to store these in a text file...

But if you really want to do it like that, just open the file, read it into a variable, then process it (and close it). How you wish to process the file (ie, search for the specials) depends entirely on how the data is stored in the file.

If you are refering to the query string in the URL, (ie, '?day=monday'), you can find what day has been specified by looking in the $_GET['day'] variable which is a predefined variable. Have a look here for more info: http://uk2.php.net/manual/en/reserve....variables.get

Regards,
Joe.
j0e is offline
Reply With Quote
View Public Profile
 
Old 08-24-2004, 11:47 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Sounds like a college assignment to me that does.

Ibbo
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 08-24-2004, 12:23 PM
Junior Talker

Posts: 3
Location: Ukraine
Trades: 0
really, you'd better create a database with a restraunt menu and add a separate field marking that the entry is "special"
it can be an enum field:
special enum('yes', 'no')

then search for the records with appropriate date and add condition AND special="yes"
this is the right approach for your task
grigori is offline
Reply With Quote
View Public Profile Visit grigori's homepage!
 
Old 08-25-2004, 05:36 AM
Ultra Talker

Posts: 377
Trades: 0
agree. it's better to use a database in such a situation...
__________________
andrews_john

Please login or register to view this content. Registration is FREE
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 08-25-2004, 09:23 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Sometimes, for such small amounts of data, a relational database is overkill and would just slow down the server more than help. As for this being a school project I too am weary to give you much so I will tell you to look here http://www.php.net/manual/en/ref.filesystem.php and you can figure it out from there.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 08-30-2004, 12:41 PM
Junior Talker

Posts: 4
Trades: 0
Not a school project actually...
I'm helping out a friend with a company website - he's wants something that he can easily edit without me having to teach him html. I thought if I had a text file he could change, it could be used to build a table in a web page.
Choaderboy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Searching a text file (PHP)
 

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.24744 seconds with 12 queries