Dynadot โ€” .com Transfer

Some php howto?

Spacemail by SpaceshipSpacemail by Spaceship
Watch

whyme953

Established Member
Impact
1
hi,

i am trying to do as follows:
i have some info that changes every week, every week i would like to display that weeks info.
i'm not sure if this is the best way to go about it but what i was thinking is to use the file () function with a list of every weeks info.
what do i need to do in order to display a different element of the array each week? (the correct one for that week)

thanks.
any help is greatly appreciated.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Not sure where your getting stuck.

just name your text files 01.txt to 52.txt

then use fread() as described here.
http://us2.php.net/manual/en/function.fread.php

It all depends how you want to display the data.
Lot of tips on delimiting your data on that page.
 
0
•••
lol, thats a good idea. I use it the same basically for flash and XML feeds!
 
0
•••
Originally posted by sadcox66
Not sure where your getting stuck.

just name your text files 01.txt to 52.txt

then use fread() as described here.
http://us2.php.net/manual/en/function.fread.php

It all depends how you want to display the data.
Lot of tips on delimiting your data on that page.
thanks alot for your help, however, i dont think i explained myself properly.
first of all let me begin by saying that i am very new to php (as well as to web design in general).
what i want to change every week is only a couple of words or strings in a sentence, but i want it to change every week automatically.

i.e. (not exactly what i want to say, rather the general idea)
<?php
print "this week shabbat begins at $begins pm EDT and ends at $ends pm EDT"
?>

what i meant when i spoke about using the file function was to make a list of all the times and using the file function to return the list as an array.
my problem is how could i set it up that the value of $begins moves (increments?) every week to the next element of the array, which is the proper time for that week?

i'm not sure if the whole array thing is the right way to go about doing this but with my limited knowledge of php its the only thing i could think of.

the only way i know of would be to use a if / elseif conditional with 52 different conditions. i figure there's gotta be an easier way to do it.
thanks again for the help
 
0
•••
so, do you wanna have this thing set up where all you do is change some things and every week, it updates?
 
0
•••
no, what i want to do is set it up once in the beginning of the year and have it update itself every week
 
0
•••
ok, so i assume you would want to write the txt files or whatever new every week? you could prolly use a simple like, if date = 2nd week or something to change on the week.
 
0
•••
make a new file name it times.php, in the file put

<?php
$begins = begintime;
$ends = endtime;
?>

In you index file add:
<?php
require 'times.php';
print "this week shabbat begins at $begins pm EDT and ends at $ends pm EDT";
?>

Now, each week when you want to cahnge the times just go into times.php and change them
 
0
•••
but he doent what to, lol, he wants it to run once, and then my just automated right? and how would u get the time? i mean, i get what your trying to do, but it doesnt seem like your getting the sys time.
 
0
•••
hmm, maybe he wants a form that he can input the start and end time in so he doesn't hav to directly edit the files, that ouwld be easy to do with my code
 
0
•••
Ya. but how wouldyou call the date/time from the script? is there someting where you just call it from the server? like an IP is easy, is there something like that for date/time
 
0
•••
he would have to input the start time and end time in times.php, the require function will call all of the variables in times.php, the variables are then used in the sentence.
 
Last edited:
0
•••
me?
 
0
•••
why not as already said have 52 text files each file would contain:-

<?php
$begins = "5pm";
$ends = "7pm";
?>

each file would have the correct times in for that week and each file could be named after its week number, then simply use the date function to find which week number today's date is then call the script using include($week_number.".txt")

or just use the 1 file and have an array in the 1 file the index being again the week number as found by the current date and state the start time and end time in that array

to find the week number simply look at http://uk2.php.net/strftime which gives the basic knowledge of how to do it
 
0
•••
i c, thanks for that link, its really nice!
 
0
•••
yeah the php manual is really good, I advise anyone coding in PHP to consult it regularly, if the official descriptions dont help the user remarks ussually do.
 
0
•••
Originally posted by filth
why not as already said have 52 text files each file would contain:-

<?php
$begins = "5pm";
$ends = "7pm";
?>

each file would have the correct times in for that week and each file could be named after its week number, then simply use the date function to find which week number today's date is then call the script using include($week_number.".txt")
thanks i think this is just what i'm looking for.

the only problem with it is that i need the weeks to start on sunday not on monday. i think i know what i need to do about that but i'm not sure:

i will call not only the week, but the day of the week as well.

if ($day_of_week==sun)
$week_number = $week_number++

i am very new to this so my syntax may be a little off, i'll look it up when i'm ready to do my scripting.

if i do this is there any reason to add a "else"?
 
0
•••
umm, lol, i dont know where you are from, but most places in the world,(including where the PHP manual is written), weeks do start on snuday, lol...
 
0
•••
0
•••
lol, where are they? so whats your problem if they have added it for you?
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back