By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,906 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,906 IT Pros & Developers. It's quick & easy.

keep variables in pagination

P: n/a
Hi, i'm trying to set pagination for a search i run on my website, i'll
try to explain the easiest i can:

When i click the search button on search.php, data is received and
stored in variables within results.php, MySQL structure seems to work
as expected, although i get some problems:

As soon as i click on the "Page 2" Link, i get nothing, neither results
nor page numbers.

I know why this happens: after clicking on any "Page X" link, the page
self-reloads and this changes the stored value in the VARIABLES (i
assume to 0 or nothing), therefore, MySQL structure doesn't work, since
there's no correct data to set the query.

Stating the obvious, if i set a fixed value instead of a variable my
structure perfectly works:

-> Results are displayed
-> Page numbers reflect the data stored in MySQL
-> Page numbers are fully fonctional, i can click them
in any way, and it always work.

But i cannot set a fixed value since data is defined in search.php, so
results.php cannot have a fixed values, otherwise, the search is not a
search, it's only a fixed d

So my question is how do i keep the values received from the search.php
after every self-reload of the page.

This is the code i am using:

<?php

// Database Connection
include 'db.php';

// THIS ARE THE VARIABLES TO KEEP EVERY PAGE RELOAD

$table = $_POST['table'];
$data02 = $_POST['data02'];
$data03 = $_POST['data03'];
$data04 = $_POST['data04'];
$data05 = $_POST['data05'];
$data06 = $_POST['data06'];
$data07 = $_POST['data07'];
$data08 = $_POST['data08'];
$data09 = $_POST['data09'];

// If current page number, use it if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page

$max_results = 10;

// Figure out the limit for the query based on the current page number.

$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

// THIS VARIABLES DATA (DECLARED ABOVE) IS ERASED AFTER THE PAGE RELOAD
// THIS IS THE DATA I'D LIKE TO KEEP FOR EVERY RELOAD.

$sql = mysql_query("SELECT * FROM `$table` WHERE `data02` LIKE
'%$data02%' AND `data03` LIKE '%$data03%' AND `data04` LIKE '%$data04%'
AND `data05` LIKE '%$data05%' AND `data06` LIKE '%$data06%' AND
`data07` >= $data08 AND `data07` <= $data09 ORDER BY `data07` ASC LIMIT
$from, $max_results");

echo '<table id="cssstyle">'."\n";
echo "<tr> <th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th>"."\n"."</tr>"."\n";

while($row = mysql_fetch_array($sql)){ // Build your formatted
below.

echo '<tr>'."\n"."<td align='left'>"."\n";
echo $row['1strow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['2ndrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['3rdrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['4throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['5throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['6throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['7throw'];
echo "\n"."</td>"."\n"."<td width='28%' align='left'>"."\n";
echo $row['8throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['9throw'];
echo "</a>"."\n"."</td>"."\n"."</tr>"."\n"."\n";
}
echo "</table>"."\n"."</div>"."\n"."<!-- Results-wrapper Ends
-->"."\n";

// Figure out the total number of results in DB:

// "$table" VALUE IS NOT KEEPT AFTER PAGE RELOADS.
// AND LIKE THE OTHER VALUES, IT SHOULD BE KEPT.

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM
$table"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<div id='pages'><center>Select a Page<br />";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$prev\">&lt;&lt;Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next&gt;&gt;</a>";
}
echo "</center>"."\n";

?>

I hope you can help me, i'm don't master php, but i understand a lot of
it; I'm actually thinking that what might solve my problem will come
from something like:
http://www.mysite.com/results.php?pa...03=XX&var04=XX

But that's exactly what i don't know how to do U_U

Thanks, and i hope you could help me

Regards,
EOZyo.

Feb 9 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
d
"EOZyo" <eo****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi, i'm trying to set pagination for a search i run on my website, i'll
try to explain the easiest i can:

When i click the search button on search.php, data is received and
stored in variables within results.php, MySQL structure seems to work
as expected, although i get some problems:

As soon as i click on the "Page 2" Link, i get nothing, neither results
nor page numbers.

I know why this happens: after clicking on any "Page X" link, the page
self-reloads and this changes the stored value in the VARIABLES (i
assume to 0 or nothing), therefore, MySQL structure doesn't work, since
there's no correct data to set the query.

Stating the obvious, if i set a fixed value instead of a variable my
structure perfectly works:

-> Results are displayed
-> Page numbers reflect the data stored in MySQL
-> Page numbers are fully fonctional, i can click them
in any way, and it always work.

But i cannot set a fixed value since data is defined in search.php, so
results.php cannot have a fixed values, otherwise, the search is not a
search, it's only a fixed d

So my question is how do i keep the values received from the search.php
after every self-reload of the page.

This is the code i am using:

<?php

// Database Connection
include 'db.php';

// THIS ARE THE VARIABLES TO KEEP EVERY PAGE RELOAD

$table = $_POST['table'];
$data02 = $_POST['data02'];
$data03 = $_POST['data03'];
$data04 = $_POST['data04'];
$data05 = $_POST['data05'];
$data06 = $_POST['data06'];
$data07 = $_POST['data07'];
$data08 = $_POST['data08'];
$data09 = $_POST['data09'];

// If current page number, use it if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page

$max_results = 10;

// Figure out the limit for the query based on the current page number.

$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

// THIS VARIABLES DATA (DECLARED ABOVE) IS ERASED AFTER THE PAGE RELOAD
// THIS IS THE DATA I'D LIKE TO KEEP FOR EVERY RELOAD.

$sql = mysql_query("SELECT * FROM `$table` WHERE `data02` LIKE
'%$data02%' AND `data03` LIKE '%$data03%' AND `data04` LIKE '%$data04%'
AND `data05` LIKE '%$data05%' AND `data06` LIKE '%$data06%' AND
`data07` >= $data08 AND `data07` <= $data09 ORDER BY `data07` ASC LIMIT
$from, $max_results");

echo '<table id="cssstyle">'."\n";
echo "<tr> <th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th>"."\n"."</tr>"."\n";

while($row = mysql_fetch_array($sql)){ // Build your formatted
below.

echo '<tr>'."\n"."<td align='left'>"."\n";
echo $row['1strow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['2ndrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['3rdrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['4throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['5throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['6throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['7throw'];
echo "\n"."</td>"."\n"."<td width='28%' align='left'>"."\n";
echo $row['8throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['9throw'];
echo "</a>"."\n"."</td>"."\n"."</tr>"."\n"."\n";
}
echo "</table>"."\n"."</div>"."\n"."<!-- Results-wrapper Ends
-->"."\n";

// Figure out the total number of results in DB:

// "$table" VALUE IS NOT KEEPT AFTER PAGE RELOADS.
// AND LIKE THE OTHER VALUES, IT SHOULD BE KEPT.

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM
$table"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<div id='pages'><center>Select a Page<br />";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$prev\">&lt;&lt;Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next&gt;&gt;</a>";
}
echo "</center>"."\n";

?>

I hope you can help me, i'm don't master php, but i understand a lot of
it; I'm actually thinking that what might solve my problem will come
from something like:
http://www.mysite.com/results.php?pa...03=XX&var04=XX

But that's exactly what i don't know how to do U_U

Thanks, and i hope you could help me

Regards,
EOZyo.


Take a look at using sessions:

http://www.php.net/sessions

They allow you to store a value in one script, and then access it in later
scripts. They're very easy to use, and might be what you need.

dave
Feb 9 '06 #2

P: n/a
You could pass them in the query string, but that is cumbersome, You
could also put all the variables in to hidden inputs, then instead of
making the next page link href directly to the next page have it do a
javascript form.submit.

Feb 9 '06 #3

P: n/a
i haven't read through it ,but i wish something below can be helpful!

if(empty($_SESSION['search_sql']) && isset($_POST[submit])){
// to construct search_sql
$search_sql = ......
$SESSION[search_sql] = $search_sql;
}else{
$search_sql = $_SESSION[search_sql];
}

$per_page = 20;
$start = ($pageno-1)*$per_page;

$query = mysql_query($search_sql." LIMIT ".$start.",".$per_page,$link);
............

Feb 9 '06 #4

P: n/a
$_POST variables are only posted at one request, they are neither a
cookie or a session.

try using sessions :)

Feb 9 '06 #5

P: n/a
Well, i started working with cookies, what i did to solve the problem
is the following:

Data is sent from page.php into search.php which stores the information
in cookies and this page forwards to results.php

-> Data from page.php is sent with a search box that uses POST.
-> Data received from page.php into search.php is taken with
$_POST['table']
-> Data in results.php is retreived with $_COOKIE['table']

Do you think this is fine or should i look for something more direct?
what i mean is straight from page.php into results.php.

Everything is working PERFECTLY with this structure, i'm just wondering
if it's practical or if i'm probably repeating a step that i could
avoid.

Thank you all!

Feb 10 '06 #6

P: n/a

"d" <d@example.com> wrote in message
news:6%******************@text.news.blueyonder.co. uk...
"EOZyo" <eo****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi, i'm trying to set pagination for a search i run on my website, i'll
try to explain the easiest i can:

When i click the search button on search.php, data is received and
stored in variables within results.php, MySQL structure seems to work
as expected, although i get some problems:

As soon as i click on the "Page 2" Link, i get nothing, neither results
nor page numbers.

I know why this happens: after clicking on any "Page X" link, the page
self-reloads and this changes the stored value in the VARIABLES (i
assume to 0 or nothing), therefore, MySQL structure doesn't work, since
there's no correct data to set the query.

Stating the obvious, if i set a fixed value instead of a variable my
structure perfectly works:

-> Results are displayed
-> Page numbers reflect the data stored in MySQL
-> Page numbers are fully fonctional, i can click them
in any way, and it always work.

But i cannot set a fixed value since data is defined in search.php, so
results.php cannot have a fixed values, otherwise, the search is not a
search, it's only a fixed d

So my question is how do i keep the values received from the search.php
after every self-reload of the page.

This is the code i am using:

<?php

// Database Connection
include 'db.php';

// THIS ARE THE VARIABLES TO KEEP EVERY PAGE RELOAD

$table = $_POST['table'];
$data02 = $_POST['data02'];
$data03 = $_POST['data03'];
$data04 = $_POST['data04'];
$data05 = $_POST['data05'];
$data06 = $_POST['data06'];
$data07 = $_POST['data07'];
$data08 = $_POST['data08'];
$data09 = $_POST['data09'];

// If current page number, use it if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page

$max_results = 10;

// Figure out the limit for the query based on the current page number.

$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

// THIS VARIABLES DATA (DECLARED ABOVE) IS ERASED AFTER THE PAGE RELOAD
// THIS IS THE DATA I'D LIKE TO KEEP FOR EVERY RELOAD.

$sql = mysql_query("SELECT * FROM `$table` WHERE `data02` LIKE
'%$data02%' AND `data03` LIKE '%$data03%' AND `data04` LIKE '%$data04%'
AND `data05` LIKE '%$data05%' AND `data06` LIKE '%$data06%' AND
`data07` >= $data08 AND `data07` <= $data09 ORDER BY `data07` ASC LIMIT
$from, $max_results");

echo '<table id="cssstyle">'."\n";
echo "<tr> <th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th>"."\n"."</tr>"."\n";

while($row = mysql_fetch_array($sql)){ // Build your formatted
below.

echo '<tr>'."\n"."<td align='left'>"."\n";
echo $row['1strow']; echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['2ndrow'];
why not just simplify this to...
echo "\n</td>\n<td align='center'>\n$row[2ndrow]";
that other way looke like the hard way to do things. And if you need double
quotes in the string, just use \"
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['3rdrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['4throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['5throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['6throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['7throw'];
echo "\n"."</td>"."\n"."<td width='28%' align='left'>"."\n";
echo $row['8throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['9throw'];
echo "</a>"."\n"."</td>"."\n"."</tr>"."\n"."\n";
}
echo "</table>"."\n"."</div>"."\n"."<!-- Results-wrapper Ends
-->"."\n";

// Figure out the total number of results in DB:

// "$table" VALUE IS NOT KEEPT AFTER PAGE RELOADS.
// AND LIKE THE OTHER VALUES, IT SHOULD BE KEPT.

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM
$table"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<div id='pages'><center>Select a Page<br />";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$prev\">&lt;&lt;Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next&gt;&gt;</a>";
}
echo "</center>"."\n";

?>

I hope you can help me, i'm don't master php, but i understand a lot of
it; I'm actually thinking that what might solve my problem will come
from something like:
http://www.mysite.com/results.php?pa...03=XX&var04=XX

But that's exactly what i don't know how to do U_U

Thanks, and i hope you could help me

Regards,
EOZyo.


Take a look at using sessions:

http://www.php.net/sessions

They allow you to store a value in one script, and then access it in later
scripts. They're very easy to use, and might be what you need.

dave

Feb 16 '06 #7

P: n/a

"EOZyo" <eo****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi, i'm trying to set pagination for a search i run on my website, i'll
try to explain the easiest i can:

When i click the search button on search.php, data is received and
stored in variables within results.php, MySQL structure seems to work
as expected, although i get some problems:

As soon as i click on the "Page 2" Link, i get nothing, neither results
nor page numbers.

I know why this happens: after clicking on any "Page X" link, the page
self-reloads and this changes the stored value in the VARIABLES (i
assume to 0 or nothing), therefore, MySQL structure doesn't work, since
there's no correct data to set the query.

Stating the obvious, if i set a fixed value instead of a variable my
structure perfectly works:

-> Results are displayed
-> Page numbers reflect the data stored in MySQL
-> Page numbers are fully fonctional, i can click them
in any way, and it always work.

But i cannot set a fixed value since data is defined in search.php, so
results.php cannot have a fixed values, otherwise, the search is not a
search, it's only a fixed d

So my question is how do i keep the values received from the search.php
after every self-reload of the page.

This is the code i am using:

<?php

// Database Connection
include 'db.php';

// THIS ARE THE VARIABLES TO KEEP EVERY PAGE RELOAD

$table = $_POST['table'];
$data02 = $_POST['data02'];
$data03 = $_POST['data03'];
$data04 = $_POST['data04'];
$data05 = $_POST['data05'];
$data06 = $_POST['data06'];
$data07 = $_POST['data07'];
$data08 = $_POST['data08'];
$data09 = $_POST['data09'];

// If current page number, use it if not, set one!

if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}

// Define the number of results per page

$max_results = 10;

// Figure out the limit for the query based on the current page number.

$from = (($page * $max_results) - $max_results);

// Perform MySQL query on only the current page number's results

// THIS VARIABLES DATA (DECLARED ABOVE) IS ERASED AFTER THE PAGE RELOAD
// THIS IS THE DATA I'D LIKE TO KEEP FOR EVERY RELOAD.

$sql = mysql_query("SELECT * FROM `$table` WHERE `data02` LIKE
'%$data02%' AND `data03` LIKE '%$data03%' AND `data04` LIKE '%$data04%'
AND `data05` LIKE '%$data05%' AND `data06` LIKE '%$data06%' AND
`data07` >= $data08 AND `data07` <= $data09 ORDER BY `data07` ASC LIMIT
$from, $max_results");

echo '<table id="cssstyle">'."\n";
echo "<tr> <th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th> <th>Top</th> <th>Top</th> <th>Top</th>
<th>Top</th>"."\n"."</tr>"."\n";

while($row = mysql_fetch_array($sql)){ // Build your formatted
below.

echo '<tr>'."\n"."<td align='left'>"."\n";
echo $row['1strow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['2ndrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['3rdrow'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['4throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['5throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['6throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['7throw'];
echo "\n"."</td>"."\n"."<td width='28%' align='left'>"."\n";
echo $row['8throw'];
echo "\n"."</td>"."\n"."<td align='center'>"."\n";
echo $row['9throw'];
echo "</a>"."\n"."</td>"."\n"."</tr>"."\n"."\n";
}
echo "</table>"."\n"."</div>"."\n"."<!-- Results-wrapper Ends
-->"."\n";

// Figure out the total number of results in DB:

// "$table" VALUE IS NOT KEEPT AFTER PAGE RELOADS.
// AND LIKE THE OTHER VALUES, IT SHOULD BE KEPT.

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM
$table"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<div id='pages'><center>Select a Page<br />";

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$prev\">&lt;&lt;Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}

// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next&gt;&gt;</a>";
}
echo "</center>"."\n";

?>

I hope you can help me, i'm don't master php, but i understand a lot of
it; I'm actually thinking that what might solve my problem will come
from something like:
http://www.mysite.com/results.php?pa...03=XX&var04=XX

That URL there is what you would use $_GET[] to get your form variables
with.
Even if your form method is set for post, you can still use get, but you
will notice that when people hit the back button on their browser your old
variables will come back on you, so be picky about when you use the url for.
Actually, I think it can also repost old form data too, especially if the
user hits refresh.
Use $_POST for post form vars of course.
You also have the option of using $_SESSION[]
http://us3.php.net/manual/en/function.session-start.php to keep data between
pages, which is a good way to hide it.
But that's exactly what i don't know how to do U_U

Thanks, and i hope you could help me

Regards,
EOZyo.

Feb 16 '06 #8

P: n/a
> why not just simplify this to...
echo "\n</td>\n<td align='center'>\n$row[2ndrow]";
that other way looke like the hard way to do things. And if you need double
quotes in the string, just use \"


Hi Jim, thanks for the advice, i've have changed everything in my
source code so it's more "legible" now :)

I'm new with PHP and i've learned everything i know from tutorials on
the net, the problem with them is that sometimes, little things (like
\', \t, \n \") are overseen and ppl ignore them since they are rookies
mistakes, but rookies (like me) well, don't know about them and we,
actually, make those mistakes :S

Thanks again for the tip :D

I have a question though, what's better to use (in a very general way)
SESSIONS or COOKIE? I mean i worked already with cookies and everything
works but if i need to learn one or the other, what would be the best?

Regards,
EOZyo

Feb 18 '06 #9

P: n/a
"EOZyo" <eo****@gmail.com> wrote:

I have a question though, what's better to use (in a very general way)
SESSIONS or COOKIE? I mean i worked already with cookies and everything
works but if i need to learn one or the other, what would be the best?


Every time you create a cookie, you are sending more crapola over to the
client computer, to be stored on their hard disk, and ALL of your cookies
are transmitted back to you with EVERY http request the browser makes.

With a session, PHP basically sends one cookie, and then uses that cookie
to look up information that is stored locally, on your server. The
bandwidth impact is much lower.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Feb 18 '06 #10

P: n/a
Hi Tim, thanks for clarifying, i guess that switching from cookies to
sessions isn't a big mess, is it? I mean, I would only have to change
the code and settings related to $_COOKIE for $_SESSION??

What i meant is like in results.php i have $foo =
$_COOKIE['something']; i should change that for $foo =
$_SESSION['something']; obviously, setting the session_start and stuff
like that in the respective pages (the one the stores the info and the
one that retrieves it, am i right?

Thanks!
EOZyo

Every time you create a cookie, you are sending more crapola over to the
client computer, to be stored on their hard disk, and ALL of your cookies
are transmitted back to you with EVERY http request the browser makes.

With a session, PHP basically sends one cookie, and then uses that cookie
to look up information that is stored locally, on your server. The
bandwidth impact is much lower.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.


Feb 19 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.