| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | some php howto? 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. |
| |
| | #2 (permalink) |
| New Member Join Date: Mar 2004
Posts: 2
![]() | 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.
__________________ osCommerce Loaded Shopping Cart |
| |
| | THREAD STARTER #4 (permalink) | ||||
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() |
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. ????: NamePros.com http://www.namepros.com/programming/36356-some-php-howto.html 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 | ||||
| |
| | THREAD STARTER #6 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | no, what i want to do is set it up once in the beginning of the year and have it update itself every week
__________________ Bais Menachem |
| |
| | #8 (permalink) |
| Senior Member Join Date: Apr 2004
Posts: 1,189
![]() ![]() ![]() | 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 |
| |
| | #12 (permalink) |
| Senior Member Join Date: Apr 2004
Posts: 1,189
![]() ![]() ![]() | 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 by e39m5; 06-30-2004 at 11:53 AM.
|
| |
| | #14 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #16 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #17 (permalink) | ||||
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() |
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"? | ||||
| |
| | THREAD STARTER #19 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | yeah MY week begins on sunday but the problem is that the numbering system for the weeks (ISO-8601 whatever that is) starts their week on monday (go figure) http://us3.php.net/manual/en/function.date.php format character W
__________________ Bais Menachem |
| |
| | THREAD STARTER #21 (permalink) | ||||
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | sorry i meant to say that the week numbers go from monday to monday not that they start their week on monday.
| ||||
| |
| | THREAD STARTER #23 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | i dont think i'm following you... i dont think you're following me... that W is the format character to get the week number with the date function echo date ("W"); // prints the week number
__________________ Bais Menachem |
| |
| | THREAD STARTER #25 (permalink) |
| NamePros Member Join Date: Jun 2004
Posts: 92
![]() | i am really not following you, i have no idea what you're trying to say...
__________________ Bais Menachem |
| |