473,748 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with session count code

I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk. I'm sure you will get the drift if you look at the code
below.

However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?

Many thanks,

Chris

if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}

Nov 2 '07 #1
7 2557
On Nov 2, 7:19 pm, Chris <matchett...@go oglemail.comwro te:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk. I'm sure you will get the drift if you look at the code
below.

However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
What do you mean by "seems to be unreliable?"
Nov 2 '07 #2
Chris wrote:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk. I'm sure you will get the drift if you look at the code
below.

However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?

Many thanks,

Chris

if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}
I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.
Nov 3 '07 #3
On 3 Nov, 06:12, Chris Gorospe <ch...@ekast.co mwrote:
Chris wrote:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk. I'm sure you will get the drift if you look at the code
below.
However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
Many thanks,
Chris
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}

I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.- Hide quoted text -

- Show quoted text -
It is not reliable in that when a link is clicked it doesn't always
add or take away 1 appropiately?

Cheers,

Chris

Nov 3 '07 #4
On 3 Nov, 06:12, Chris Gorospe <ch...@ekast.co mwrote:
Chris wrote:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk. I'm sure you will get the drift if you look at the code
below.
However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
Many thanks,
Chris
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}

I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.- Hide quoted text -

- Show quoted text -
Just to clarify why I need help.

If I use the code above when I click my add '>>' link first time all
is ok. The next take away click '<<' adds 1 then starts taking away 1
with further clicks. Returning to '>>' takes away 1 and then continues
to add 1?

Very confused?!

Cheers,

Chris

Nov 3 '07 #5
Chris wrote:
On 3 Nov, 06:12, Chris Gorospe <ch...@ekast.co mwrote:
>Chris wrote:
>>I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstW k. I'm sure you will get the drift if you look at the code
below.
However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
Many thanks,
Chris
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}
I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.- Hide quoted text -

- Show quoted text -

Just to clarify why I need help.

If I use the code above when I click my add '>>' link first time all
is ok. The next take away click '<<' adds 1 then starts taking away 1
with further clicks. Returning to '>>' takes away 1 and then continues
to add 1?

Very confused?!

Cheers,

Chris

Then you aren't telling us the entire story, Chris. This code won't
work that way.

Let's see ALL the code you're using.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 3 '07 #6
On 3 Nov, 13:44, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Chris wrote:
On 3 Nov, 06:12, Chris Gorospe <ch...@ekast.co mwrote:
Chris wrote:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstWk . I'm sure you will get the drift if you look at the code
below.
However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
Many thanks,
Chris
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}
I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.- Hide quoted text -
- Show quoted text -
Just to clarify why I need help.
If I use the code above when I click my add '>>' link first time all
is ok. The next take away click '<<' adds 1 then starts taking away 1
with further clicks. Returning to '>>' takes away 1 and then continues
to add 1?
Very confused?!
Cheers,
Chris

Then you aren't telling us the entire story, Chris. This code won't
work that way.

Let's see ALL the code you're using.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===- Hide quoted text -

- Show quoted text -
Jerry,

All code attached.

Cheers,

Chris

// Count for weekno
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
}
if($_GET['nxtWk'] == '1') {
$_SESSION['count']++;
}
if($_GET['lstWk'] == '1') {
$_SESSION['count']--;
}

$_SESSION['weeknumber'] = date('W')+$_SES SION['count'];

--html--
<p><a href="index.php ?lstWk=1">&lt;& lt;</aBack Next <a
href="index.php ?nxtWk=1">&gt;& gt;</a>
<?=$_SESSION['weeknumber']; ?>
</p>

Nov 3 '07 #7
Chris wrote:
On 3 Nov, 13:44, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Chris wrote:
>>On 3 Nov, 06:12, Chris Gorospe <ch...@ekast.co mwrote:
Chris wrote:
I am trying to increase/decrease the value of $_SESSION['count'] by 1
after clicking on a link e.g index.php?gotoW k=nxtWk and index.php?
gotoWk=lstW k. I'm sure you will get the drift if you look at the code
below.
However, this code seems to be unreliable. Is there a more robust way
of achieving the same thing?
Many thanks,
Chris
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
} elseif($_REQUES T['gotoWk'] == "nxtWk") {
$_SESSION['count']++;
} elseif($_REQUES T['gotoWk'] == "lstWk") {
$_SESSION['count']--;
}
I don't see what why you think it's unreliable. Looks like it should do
exactly what you're explaining you want done. The only thing i'd
personally change is the $_REQUEST. I would use $_GET instead.- Hide quoted text -
- Show quoted text -
Just to clarify why I need help.
If I use the code above when I click my add '>>' link first time all
is ok. The next take away click '<<' adds 1 then starts taking away 1
with further clicks. Returning to '>>' takes away 1 and then continues
to add 1?
Very confused?!
Cheers,
Chris
Then you aren't telling us the entire story, Chris. This code won't
work that way.

Let's see ALL the code you're using.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====- Hide quoted text -

- Show quoted text -

Jerry,

All code attached.

Cheers,

Chris

// Count for weekno
if (!isset($_SESSI ON['count'])) {
$_SESSION['count'] = 0;
}
if($_GET['nxtWk'] == '1') {
$_SESSION['count']++;
}
if($_GET['lstWk'] == '1') {
$_SESSION['count']--;
}

$_SESSION['weeknumber'] = date('W')+$_SES SION['count'];

--html--
<p><a href="index.php ?lstWk=1">&lt;& lt;</aBack Next <a
href="index.php ?nxtWk=1">&gt;& gt;</a>
<?=$_SESSION['weeknumber']; ?>
</p>

Why are you adding or subtracting the count from the current week number?

And why are you even storing the count in $_SESSION? You don't use it
from one page to the next.

Also, I don't see a call to session_start() .

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 3 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1656
by: Alexandre MELARD | last post by:
Hi, My name is alexandre, I am 4th year student at the Napier university of edinburgh. I am finishing my year and do a presentation of my honours project next wednesday (the 5th of May). I am doing a project of data mining, and I run a mysql database to store my data. the database structure:
28
3303
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
0
1896
by: john | last post by:
Hi,All MS Tech Gurus: I need your help!!! It is the second time I post this message, I need get some feedback ASAP, Please Help!! Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate classes & method depends on the meta table in the database,here is my situation 1) In One method I generated the code Dynamic IL Code (Depends on the data pass to it), The generated code works for one dataset but does...
5
2059
by: Marc Bishop | last post by:
I'm trying to get this to work but i'm at a loss as to how. i've searched google without much help code Dim ArrCart As new ArrayList() ArrCart = CType(Session("sesCart"), ArrayList) ArrCart.add(sID & ",1") Session("sesCart") = ArrCart So what i want to do is maintain my Arraylist of items in a session.
4
2278
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this dataSet updating lark when i realised that i think i am right back at square 1!!! Here's my scenario - i have a SQLDB and i retrieve all my data from that into a dataset and display this to a datagrid(WebForm). I have got this grid sorted and...
8
1254
by: Bruno Alexandre | last post by:
Hi guys, I'm using a session to save an ArrayList, so I do not read Database everytime user reload the page or enter the site (the Data is consistent for all entire session time when the user is on the site). I'm using a Class called ProductBoxes and inside I have a public property of Object type and I call from the PageLoad event dim boxes as new ProductBoxes
0
2477
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains the following information: intProdID -- ProductID strProdName -- Product Name intQuant -- Quantity intProdPrice -- Price productType -- Type of product (ie. Wine, Cheese, etc...)
0
2402
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event, which I am). I now want to read the text/values of those controls. I have found out that I can read the values if I wait until Page_Load, but then I have the same questions showing up again (along with the new questions) and I do not want them to....
0
5573
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
2
2985
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your standard dynamic address book program. Adding, and listing work just fine. However, deleting, editing and viewing relies on member function retAddress. This function returns an array of pointers that are pointing to created objects. In action, all it...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.