Jump to content

Session question


mhodgson

Recommended Posts

I'm not fully conversent with sessions and I suspect they are the answer to this problem but I cannot figure this one out yet.

 

I have a table with data drawn from a database and some calculated on the page.

e.g.

 

1 Name | Score 1 |Score 2 | Average Score  where average score is calculated on the page.

2 Name | Score 1 |Score 2 | Average Score

3 Name | Score 1 |Score 2 | Average Score

4 Name | Score 1 |Score 2 | Average Score

etc.

 

Can I carry this data to a new page without having to call from the database again.

The reason is that I want to sort ALL the columns (which I can do already) but then transfer that sorted table to a new page for printing.

 

 

 

 

Link to comment
Share on other sites

Can I carry this data to a new page without having to call from the database again.

 

Yes. There are however plenty of tutorials around explaining the use of sessions, do we really need to write another here?

 

All you need do is start a session using session_start, then save your values into the $_SESSION array (it works just like any other associative array), then on the page you wish to retrieve the data back from the $_SESSION array, you need to call session_start again, then grap your data from the $_SESSION array.

 

The main thing to remember is ALL pages using the $_SESSION array need a call to session_start.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.