Forum Moderators: coopster
any suggestion is appreciable
regards,
naghmeh
As is noted in the php manual for session_start() [php.net]
you must call session_start() before anything is output to the browser.
That error means exactly that, some data was outputted before you call session_start. Take a look at what is going on before your session_start. Something before it is sending output and causing the error.
Regards,
naghmeh
and then i want to have a link to my next page ,so in the new script ,again i wrote
session_start();
to take the variables and my new script to get next records,am i wrong?
maybe a snippet of code? Is the error only when you go to the second page, every page or only the first page?
for example when i show 20 of my records in a page, i want to show next 20 records in another page so i have to put a link on my page to show next 20 records, now for the first page i have to write my queries (but i think i dont have to write my queries again )so i can have a new script which takes some variables and shows next records.
i wish it is clear enough.
thank you
Naghmeh
From your advise i have looked up and found out that i have to use session_unset(); to release my variables ;
but when i use that, it just show one of my variabls and the others the same error.
about your Q that you asked if this problem is just for this page,this is the first page that i am writing with sessions.
regards,
naghmeh
The way I do this is to pass an offset to the new page and then include that offset in your query to get the proper result set.
There are a bunch of different methods to do the multi page list. Two possibilities are the "next page - previous page setup". For this one you need to pass an offset, or first record, value.
ie on the first page we would show results 1-20 therefore the previous page would be disabled and the next page would have an offset of 21. The next page shows 21-40 the previous offset is 1 and the next offset would be 41. I figure you get my drift.
The second way is to list the page numbers. In this case we have 50 results and 20 per page. We would need to do a select and then count the total results and divide by the number of records per page (20).
Then we put each page number in a list and include the starting record offset in the link. ie page1=1, page2=21, page3=41.
So you may already understand this and this may be the method you are already using but I wanted to be sure we were both on the same page.
As I have been walking myself through this using sessions to trck this seems like a strange way to do it. You would be better off just using on page methods and staying away from using the session to store the offsets or results.
Is there any particular reason you want to do it using sesions?
thank you
Naghmeh
is there a way that i can send more than one variable to next page?
yep, just keep tacking them on the end by using & between them.
like so ...
<a href="NextPage.php?j=X&var2=value&var3=value2">
Try to keep them to minimum if you can (2 or less). You may find that the links will not be spidered as they get longer.
If you have a set number of results you could even hard code the queries into each individual page, this doesn't work very well if the number of items will constantly change.
You could also use mod_rewrite [webmasterworld.com] but that can be very confusing if you are just starting out.
You can even use sessions for it but when I was working through some ideas it seemed like a more confusing way of doing it.