Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the current week number of the year

Status
Not open for further replies.

jefargrafx

Instructor
May 24, 2001
273
US
Hi yall...

I got a record set that retreives a cafeteria menu from a database. In the database I have a column that iindicates the records assigned week 1-52 for 52 weeks in the year.

I've got very thing working okay by sorting on the week number column 1-52 and I have record set navigation set so the user can page throguh the records (differnet menus)

However, I need to automaticlly move to the current week based on the sytem clock.

so when the user opens the page he see this weeks menu. (what ever this week might be)

I'm sure php can do this? any ideas on where I might look.

thanks

jef
 
very god, I got this to work and set it as a variable

$weeknumber = date("W");

and
echo $weeknumber;

print 35 to the screen, but how to I get my recordset to move to menu_week 35?

right now it get's all the records and displays them 1-52, starting at 1, week week I'd like to start at 35?

any ideas

thanks I new to PHP, but I got ta say I'm lovin it.

let me know

jef
 
You should take care of that in your SQL statement.
Code:
# 1. ascertain the current week
$currentWeek = date("W");
# construct SQL
$SQL = "SELECT * FROM menutable WHERE menuWeek = $currentWeek";

That's all. The WHERE clause limits the records to the specified condition.
 
okay guys I almost got it

this is the url I'm passing

cafeteria_startpage_00.php?pageNum_rs_getCafeteriaMenus=33

where 33 is the date("w");

however if I pass

cafeteria_startpage_00.php?pageNum_rs_getCafeteriaMenus=weeknumber

I just get weeknumber in the url
why

In my test page where I set the link I have

$weeknumber = date("W");
echo $weeknumber;

and then the link to the startpage

what am I missing?

jef
 
When you pass something as a GET parameter then that's what's in the variable - that's why.

You need to create your link within the PHP application and set the correct parameter there:
Code:
$weeknumber = date("W");
# print the link now
print(&quot;<a href=&quot;cafeteria_startpage_00.php?pageNum_rs_getCafeteriaMenus=&quot;.
Code:
$weeknumber
Code:
;
# etc.

It is your code that has to create the correct link. Hence these pages are called 'dynamic'.
 
Insufficient data for a meaningful answer. You're the only one of us that has seen your code.

As a general piece of advice, you need to build your URL string by concatenating &quot;afeteria_startpage_00.php?pageNum_rs_getCafeteriaMenus=&quot; with the value in $weeknumber. You're not doing that correctly in your PHP code.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
DRJ478

thnaks for setting me straight!

I get it now, I was trying to pass a variable of a variable on a href..... no wonder

you the best and big cookie and a thanks a lot.

I'll get there


jef
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top