Sorting with PHP and GET method? -
 I'm trying to sort them using the link and the  GET  method. I provide the code first and then explain what I am trying to achieve. Could be a better way of using AJX and making it dynamic (I think?), But I want to start it already. 
code:
  if (isset ($ _ GET ['order'])) {$ order = $ _GET ['order'];} else {$ order = 0;} if (isset ($ _GET ['field'])) {$ order_field = $ _GET ['field'];} switch ($ order) {case 0: $ order_next = "DESC"; break; Case "DESC": $ order_next = "ASC"; break; Case "ASC": $ order_next = 0; break; }   And later, I have this snippet in the HTML page:
     OK I have the  Last  link, which includes 3 terms,  default ,  DESC  command, Em> ASC  command. 
 When I click on it once, it should be sent through the GET method, the field I clicked was the "last name" field, and I need the next position (by default (sorting Without the next one (DESC in this case)). I can not catch the error completely on the code, or I do not understand anything, can not the page be loaded properly or again? When I click on the link, the  $ order  and  $ order_field  are read from the GET method, but  nothing else . For some reason  switch  does not work, and the  $ order_next  does not change in the new value, and there is only 1 link instead of 2: 
 Default: Link " Last "DESC: Link with the triangle picture indicating the" last "link. 
PS: Sorry, if I did not understand this well, but I tried. Thanks for your time!
 change  case 0:  to  "0":  and all the world will be good: -) 
This is because using the switch
To understand, just run this code and see the results:
  var_dump ("DESC" == 0);   
Comments
Post a Comment