NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page some php howto?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 06-28-2004, 02:11 PM THREAD STARTER               #1 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



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.
whyme953 is offline  
Old 06-29-2004, 06:32 PM   #2 (permalink)
New Member
Join Date: Mar 2004
Posts: 2
sadcox66 is an unknown quantity at this point
 



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
sadcox66 is offline  
Old 06-29-2004, 06:36 PM   #3 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



lol, thats a good idea. I use it the same basically for flash and XML feeds!
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-29-2004, 08:32 PM THREAD STARTER               #4 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



Quote:
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.
????: 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
whyme953 is offline  
Old 06-30-2004, 06:45 AM   #5 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



so, do you wanna have this thing set up where all you do is change some things and every week, it updates?
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 07:56 AM THREAD STARTER               #6 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



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
whyme953 is offline  
Old 06-30-2004, 08:02 AM   #7 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



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.
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 08:21 AM   #8 (permalink)
Senior Member
Join Date: Apr 2004
Posts: 1,189
e39m5 is a jewel in the roughe39m5 is a jewel in the roughe39m5 is a jewel in the rough
 



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
e39m5 is offline  
Old 06-30-2004, 08:39 AM   #9 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



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.
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 08:46 AM   #10 (permalink)
Senior Member
Join Date: Apr 2004
Posts: 1,189
e39m5 is a jewel in the roughe39m5 is a jewel in the roughe39m5 is a jewel in the rough
 



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
e39m5 is offline  
Old 06-30-2004, 09:01 AM   #11 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



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
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 09:04 AM   #12 (permalink)
Senior Member
Join Date: Apr 2004
Posts: 1,189
e39m5 is a jewel in the roughe39m5 is a jewel in the roughe39m5 is a jewel in the rough
 



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.
e39m5 is offline  
Old 06-30-2004, 09:26 AM   #13 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



me?
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 09:38 AM   #14 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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
Peter is offline  
Old 06-30-2004, 09:57 AM   #15 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



i c, thanks for that link, its really nice!
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 01:50 PM   #16 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
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
Peter is offline  
Old 06-30-2004, 03:59 PM THREAD STARTER               #17 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



Quote:
Originally posted by filth
????: NamePros.com http://www.namepros.com/showthread.php?t=36356
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"?
whyme953 is offline  
Old 06-30-2004, 06:48 PM   #18 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



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...
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 07:35 PM THREAD STARTER               #19 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



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
whyme953 is offline  
Old 06-30-2004, 07:39 PM   #20 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



lol, where are they? so whats your problem if they have added it for you?
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 07:43 PM THREAD STARTER               #21 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



sorry i meant to say that the week numbers go from monday to monday not that they start their week on monday.

Quote:
Originally posted by iDeviseFlash
so whats your problem if they have added it for you?
who added what?
whyme953 is offline  
Old 06-30-2004, 07:49 PM   #22 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



PHP, with the W, lol.
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 07:56 PM THREAD STARTER               #23 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



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
whyme953 is offline  
Old 06-30-2004, 08:10 PM   #24 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



yes, but it says on the link that it starts with monday right? im gonna go back and look.
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 06-30-2004, 08:16 PM THREAD STARTER               #25 (permalink)
NamePros Member
 
whyme953's Avatar
Join Date: Jun 2004
Posts: 92
whyme953 is an unknown quantity at this point
 



i am really not following you, i have no idea what you're trying to say...
__________________
Bais Menachem
whyme953 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:24 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger