memorising requested variables after page reset

Thread Solved

Join Date: Oct 2006
Posts: 232
Reputation: Rhyan is an unknown quantity at this point 
Solved Threads: 24
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Posting Whiz in Training

Re: memorising requested variables after page reset

 
0
  #11
Nov 19th, 2008
Yes, you are correct.

One suggestion only

this code
  1. IF ( ISSET($_GET[combo_2]) )
  2. {
  3. $combo_2 = $_GET['combo_2'];
  4. IF ( $combo_2 <> 0 ) // check to see if user has selected something other then the default
  5. {
  6. $sql_line .= "AND (cond2)";
  7. }
  8. }
you can change it like this and it will be valid.
  1. IF ( ISSET($_GET[combo_2]) && $_GET[combo_2]!=0 )
  2. {
  3. $combo_2 = $_GET['combo_2'];
  4. $sql_line .= "AND (cond2)";
  5. }
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #12
Nov 19th, 2008
oh... nevermind... I understand what you mean... ok... I will change it... then get started on the split pages...
Last edited by marcmm; Nov 19th, 2008 at 1:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #13
Nov 19th, 2008
Ok... more progress:

  1. $currentpage = 0; // I had to set the current page var to 0 outside the if isset loop because the else branch there dosen't seem to work
  2.  
  3. $sql_line="SELECT DISTINCT tables.names
  4. FROM tables
  5. WHERE ((standard cond 1 )
  6. AND (standard cond 2 )";
  7.  
  8. $sql_end=")
  9. ORDER BY something ASC";
  10.  
  11. $sql_limit=" LIMIT $currentpage,5"; // I made the first value of the limit to point to the currentpage and the second representing how many results to display per page... 5 at the moment...
  12.  
  13. IF ( ISSET($_GET[page]) )
  14. {
  15. $currentpage = $_GET['page'];
  16. }
  17. ELSE
  18. {
  19. $currentpage = 0; // this branch dosen't work... but I supose it makes sence... the page is beying sent even by default from the browse frame...
  20. }
  21.  
  22. IF ( ISSET($_GET[combo_1]) && $_GET[combo_1]!=0 )
  23. {
  24. $combo_1 = $_GET['combo_1'];
  25. $sql_line .= "AND (cond 1)";
  26. $pagelink .= "&combo_1 = $combo_1";
  27. }
  28.  
  29. IF ( ISSET($_GET[combo_2]) && $_GET[combo_2]!=0 )
  30. {
  31. $combo_2 = $_GET['combo_2'];
  32. $sql_line .= "AND (cond 2)";
  33. $pagelink .= "&combo_2 = $combo_2";
  34. }
  35.  
  36. IF ( ISSET($_GET[checkbox1]) )
  37. {
  38. $sql_line .= "AND ( cond3 )";
  39. $pagelink .= "&checkbox1 = AND ( cond3 )";
  40. }
  41.  
  42. IF ( ISSET($_GET[checkbox2]) )
  43. {
  44. $sql_line .= "AND ( cond4 )";
  45. $pagelink .= "&checkbox2 = AND ( cond4 )";
  46. }
  47.  
  48. IF ( ISSET($_GET[checkbox3]) )
  49. {
  50. $sql_line .= "AND ( cond5 )";
  51. $pagelink .= "&checkbox3 = AND ( cond5 )";
  52. }
  53.  
  54. $sql_line .= $sql_end; // I add the order part
  55.  
  56. $sql_totallines = $sql_line; // I create the string for the hidden query
  57.  
  58. $rez_totallines = mysql_query($sql_totallines) OR DIE (mysql_error()); // execute the hidden querry
  59.  
  60. $total_lines = mysql_num_rows($rez_totallines); // count the total number of rows the query will have.
  61.  
  62. $sql_hoteluridisp .= $sql_limit; // atatch the limit parameter
  63.  
  64. $rez_hoteluridisp = mysql_query($sql_hoteluridisp) OR DIE (mysql_error()); // execute the real query
  65.  
  66. $linii_hoteluridisp=mysql_num_rows($rez_hoteluridisp); // count the number of results in the new query

Is it ok so far?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 232
Reputation: Rhyan is an unknown quantity at this point 
Solved Threads: 24
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Posting Whiz in Training

Re: memorising requested variables after page reset

 
0
  #14
Nov 19th, 2008
Yes, it is ok like that... Keep on
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #15
Nov 20th, 2008
Unfortunatelly it still dosen't work... and the page calculation system is flawed...

here's what I have in adition to the above:

  1. $pagination = $total_lines/$displaylines; // ( total_lines is the variable I obtained when I did the hidden query to determine how many records my query would have without the limit parameter / display lines is a var that hoalds the number of results per page wich defaults to 5 at the begining of the page. )
  2.  
  3. IF ( is_int ( $pagination ) )
  4. {
  5. $total_pages = $pagination;
  6. }
  7.  
  8. IF ( is_float ( $pagination ) )
  9. {
  10. $total_pages = $pagination + 1;
  11. }
  12.  
  13. FOR ($i=0; $i<$total_pages; $i++)
  14. {
  15. ECHO "<a href='display.php?page=$i$pagelink'> $i </a>";
  16. }

well first of all the page count is always wrong... at present my DB hoalds just 6 entries... if just hit search and not select anything ( meaning that I want to display all the records ) the division should be 5 records on first page and 1 record on a second page...

the calculation should be:

  1. $pagination=6/5=1.2; // that's float so it should take this route:
  2.  
  3. IF ( is_float ( $pagination ) )
  4. {
  5. $total_pages = $pagination + 1=2.2; ( is there no way to just take the integer part of a number? not rounding it )
  6. }

the code will display 3 pages... namelly 0 1 and 2... and their code dose not work either...

when I seelct either of them I will either loose all or part of the atributes contained in the $pagelink string. and the same page loads with the same results...basicly I still loose the parameters allong the way and even if some of the parameters do make it through the reload they don't seem to work...

this is how the link to one of the pages looks like if I rightclick on it:

mydomain/display.php?page=1&combo_1%20=%201 ( this is suposing I changed the first dropdown list and selected something other then the default from it ).

Now suposedly when It reloads the page it's suposed to do this:

  1. IF ( ISSET($_GET[combo_1]) && $_GET[combo_1]!=0 ) ( bolth are suposed to be true since I selected option 1 from the list so it should be set AND different from 0 )
  2. {
  3. $combo_1 = $_GET['combo_1']; // suposed to give the passed variable back to the original var. dosen't seem to happen.
  4. $sql_line= "AND (localitate.ID = $combo_localitatedisp)"; // same as above... it's not executed.
  5. $pagelink .= "&combo_localitatedisp = $combo_localitatedisp"; // this either...
  6. }

so on the new page there's no parameters and the page loads all the results reguardless of what I had selected originally...

EDIT: I just checked... the IF statement is not even executed when I reload the page... the if isset dosen't recognise that I'm sending parameters via the reload link and just skips theentire tree. the problem must lie in the transmited string $pagelink!

I experiance a similar problem with the checkboxes... if I have all the checkboxes selected when I click on a new page I'll loose all but one of the checkbox parameters and that one that persists is never used and the page will still load all the records ( well it will still be limited to that wich is written in the limit parameter as the current page... )

What am I doing wrong?
Last edited by marcmm; Nov 20th, 2008 at 4:25 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #16
Nov 20th, 2008
I've noticed that the link seems to have certain problems sending the combo parameters...

they are under this form:

  1. &combo1='number'

but the link will only say &combo1=

seems as though it has problems reading ' characters or something...

Wich means either it transmits an empty parameter to the reloaded page... or it dosen't transmit anything... reguardless... on the next page the if isset structures are not executed ( well except for the page if isset tree... that one works ).
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 232
Reputation: Rhyan is an unknown quantity at this point 
Solved Threads: 24
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Posting Whiz in Training

Re: memorising requested variables after page reset

 
0
  #17
Nov 20th, 2008
Sorry, my bad - use % instead of / for division of total numbers against display numbers. I don't know exactly in English how this division is called, but the result is integer with remaining result that is indivisible. That is the result will be 6%5=1 and remaining 1 record to be displayed on page 2.

Now, about your checkboxes. As I mentioned earlier - if you check some checkboxes, you need to hit the submit button, not the next page number. The next page number will execute the same search query as your previous search, without modification. In order to change your query params you have to use your search form and the submit button.
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #18
Nov 20th, 2008
it still dosen't work...

6%5

and going through this:

  1. IF ( is_float ( $pagination ) )
  2. {
  3. $total_pages = $pagination + 1;
  4. }

still gives 3 pages instead of 2...

And I STILL loose all my parameters when I click any of the page links... so when the page reloads and reexecutes the query it dosen't have the parameters and what happenes is that it ends up executing the query with no parameters...

the problem has to be in the transmit line:

  1. ECHO "<a href='display.php?page=$i$pagelink'> $i </a>";

cause up untill there the strings are all fine... but once I hit any of those links... I losoe all my parameters... namelly everything contained inthe &pagelink variable...

are you sure that it's the "&" symbol that ties multyple variables to be sent with the ? symbol from page to page?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #19
Nov 20th, 2008
Ok... I belive I fixed it... It seems to work properly now... my errore seems to have steemed from the fact that I had a few variables in highercase in some areas... and sicne var names are casesensitive... it pushed the entire system overboard...

Gona do some testing to make sure everythign works then I'll post my solution ( if nothing else comes up ).
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 42
Reputation: marcmm is an unknown quantity at this point 
Solved Threads: 0
marcmm marcmm is offline Offline
Light Poster

Re: memorising requested variables after page reset

 
0
  #20
Nov 24th, 2008
Well I tested it and it works... so problem solved... thanks for the input guys... using the get methode and implementing the posting and retrieving of data from page to page was something I doubt I would have figured out on my own...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC