Kibit Posted November 10, 2008 Share Posted November 10, 2008 I currently use this time related content php script... <?php $now = date("D_H:00"); *SNIP* $shows['Sat_15:00']['title']="15:00 - 16:00 SHOW INFO"; $shows['Sat_16:00']['title']="16:00 - 17:00 SHOW INFO"; $shows['Sat_17:00']['title']="17:00 - 18:00 SHOW INFO"; *SNIP* echo $shows[date("D_H:00")]['title']; ?> What I want/need to add is this line <?php $point = file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt'); echo $point; ?> I have tried this.... <?php $now = date("D_H:00"); *SNIP* $shows['Sat_15:00']['title']="<?php $point = file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt'); echo $point; ?>"; $shows['Sat_16:00']['title']="16:00 - 17:00 SHOW INFO"; $shows['Sat_17:00']['title']="17:00 - 18:00 SHOW INFO"; *SNIP* echo $shows[date("D_H:00")]['title']; ?> Which does not work! now as you've prob guessed by the fact I even tried that I'm not very good at this php! So what do I need to change to make it show the info from the .txt files? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 10, 2008 Share Posted November 10, 2008 Try <?php $now = date("D_H:00"); *SNIP* $point = trim(file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt')); $shows['Sat_15:00']['title']= $point; $shows['Sat_16:00']['title']="16:00 - 17:00 SHOW INFO"; $shows['Sat_17:00']['title']="17:00 - 18:00 SHOW INFO"; *SNIP* echo $shows[date("D_H:00")]['title']; ?> Ken Quote Link to comment Share on other sites More sharing options...
Kibit Posted November 10, 2008 Author Share Posted November 10, 2008 but the "file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt'));" will be differant for each hour I know this is not going to work in my example but you should get the idea.... <?php $now = date("D_H:00"); *SNIP* $shows['Sat_15:00']['title']="<?php $point = file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt'); echo $point; ?>"; $shows['Sat_16:00']['title']="<?php $point = file_get_contents('/home/*****/public_html/*****/data/sat-1600-1700.txt'); echo $point; ?>"; $shows['Sat_17:00']['title']="<?php $point = file_get_contents('/home/*****/public_html/*****/data/sat-1700-1800.txt'); echo $point; ?>"; ETC ETC *SNIP* echo $shows[date("D_H:00")]['title']; ?> Remember this is just a small snippet where is says etc etc the same code continues for on the hour 7 days a week. The idea being that I can edit the individual txt files and the info will change across the site at any point I decide to insert any particular "edit point" Hope that makes sense Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 10, 2008 Share Posted November 10, 2008 Please explain yourself better. What is contained in each file? It looks like you would be better off using a database here. Ken Quote Link to comment Share on other sites More sharing options...
Kibit Posted November 10, 2008 Author Share Posted November 10, 2008 OK I'll Try.... I have several files (database may well be better but this is what's already in place and working) Each file is just simply a plain text document example structure of these files... sun-0000-0100.txt sun-0100-0200.txt sun-0200-0300.txt and so on, a file for every hour of everyday for 7 days These files are editable via an already in place php script so I can allow others (other admins and its in a protected area of the site) to edit online the content of each file. Then lets say I wanted to display the contents of sunday-0000-0100.txt on 2 seperate pages of the site, no problem I simply add <php> <?php $point = file_get_contents('/home/*****/public_html/*****/data/sunday-0000-0100.txt'); echo $point; ?> </php> In the place I want the content to show on any of my pages and as its a plain text file the formatting does follow that of the page I inserted the above code into. That is all in place and working exactly as I need/want it to. Now on another part of the site we have timed content using the code I provided above, here it is again... <php> <?php $now = date("D_H:00"); *SNIP* $shows['Sat_15:00']['title']="15:00 - 16:00 SHOW INFO"; $shows['Sat_16:00']['title']="16:00 - 17:00 SHOW INFO"; $shows['Sat_17:00']['title']="17:00 - 18:00 SHOW INFO"; *SNIP* ECT ETC every hour for 7 days *SNIP* echo $shows[date("D_H:00")]['title']; ?></php> So when the visitor comes to the site they are displayed correct info for that hour, this is refreshed to keep the content the correct hour when a user saying on the same page over an hour using ajax but I digress, this part is also already up and running as needed. What I want to do for a differant area of the site is combine the 2, so the end user is delivered the content of the relivant txt file instead of the ['title']="INFO HERE" information. Make sense? Quote Link to comment Share on other sites More sharing options...
Kibit Posted November 10, 2008 Author Share Posted November 10, 2008 Ok don't matter, I have sussed it.... <?php $now = date("D_H:00"); *SNIP* $shows['Sat_15:00']['title']= file_get_contents('/home/*****/public_html/*****/data/sat-1500-1600.txt'); $shows['Sat_16:00']['title']= file_get_contents('/home/*****/public_html/*****/data/sat-1600-1700.txt'); $shows['Sat_17:00']['title']= file_get_contents('/home/*****/public_html/*****/data/sat-1700-1800.txt'); *SNIP* ECT ETC every hour for 7 days *SNIP* echo $shows[date("D_H:00")]['title']; ?> Is working exactly as I wanted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.