943,920 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2175
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Nov 19th, 2008
0

Re: memorising requested variables after page reset

Yes, you are correct.

One suggestion only

this code
PHP Syntax (Toggle Plain Text)
  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.
PHP Syntax (Toggle Plain Text)
  1. IF ( ISSET($_GET[combo_2]) && $_GET[combo_2]!=0 )
  2. {
  3. $combo_2 = $_GET['combo_2'];
  4. $sql_line .= "AND (cond2)";
  5. }
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Nov 19th, 2008
0

Re: memorising requested variables after page reset

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 19th, 2008
0

Re: memorising requested variables after page reset

Ok... more progress:

PHP Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 19th, 2008
0

Re: memorising requested variables after page reset

Yes, it is ok like that... Keep on
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Nov 20th, 2008
0

Re: memorising requested variables after page reset

Unfortunatelly it still dosen't work... and the page calculation system is flawed...

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

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 20th, 2008
0

Re: memorising requested variables after page reset

I've noticed that the link seems to have certain problems sending the combo parameters...

they are under this form:

PHP Syntax (Toggle Plain Text)
  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 ).
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 20th, 2008
0

Re: memorising requested variables after page reset

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.
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Nov 20th, 2008
0

Re: memorising requested variables after page reset

it still dosen't work...

6%5

and going through this:

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 20th, 2008
0

Re: memorising requested variables after page reset

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 ).
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008
Nov 24th, 2008
0

Re: memorising requested variables after page reset

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...
Reputation Points: 10
Solved Threads: 0
Light Poster
marcmm is offline Offline
42 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need Advice on Concepts.
Next Thread in PHP Forum Timeline: language code not showing in source view. Really weird!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC