Pagination issue: need to get a variable |
[eluser]developer10[/eluser]
I'm trying to implement pagination. i've set up everything except for $config['total_rows'] This is my model function Code: function svimodel() { notice $config['total_rows'] = ''; where a variable should be placed. at the beginning of the query i tried to put count(f_id) as number in order to get the correct number of items (with filters, ie. uri segments, applied or without them) but i was not able to pull that value (number) out. in fact, at some instance, i was getting no errors, but $row->number returned nothing (i remove code for this, to avoid messy code) this variable is needed for pagination to be rendered correctly (proper number of pagination links) any suggestions?
[eluser]Herb[/eluser]
I would suggest that you test your sql with something like phpMyadmin in every possible assemblage your code could render, then see if it returns the information you would expect. If it doesn't then you need to rework your sql until it does. Also based on the variables you set early on, $pDjelatnost and $pGrad are arrays and your if statements forming your query will always evaluate to FALSE as presented. You need to test your if statements by inserting the appropriate values that could occur to ensure they evaluate correctly, then modify as necessary. Hope this is helpful.
[eluser]developer10[/eluser]
[quote author="Herb" date="1247360498"]I would suggest that you test your sql with something like phpMyadmin in every possible assemblage your code could render, then see if it returns the information you would expect. If it doesn't then you need to rework your sql until it does. Also based on the variables you set early on, $pDjelatnost and $pGrad are arrays and your if statements forming your query will always evaluate to FALSE as presented. You need to test your if statements by inserting the appropriate values that could occur to ensure they evaluate correctly, then modify as necessary. Hope this is helpful.[/quote] look, my sql query works perfectly, i tested it with one, two, etc. parameters, and without any parameters, and it always returns what it is supposed to. when i want to apply pagination, i need that variable $config['total_rows'] because my pagination links wont render properly, since pagination function needs to know how many rows were returned by sql query. sometimes that number is , lets say 1000, and sometimes (when filters, like city and starting letter are applied, its only 80). so, that is the parameter i need. otherwise, pagination wont initialize. i dont know how to put count in my query so i can later retrieve number of rows that were returned by the query. whats already in the query simply doesn't return anything: Code: SELECT *, [b]count(f_id) AS cifra[/b], tbl_djelatnosti.djelatnost FROM so if you have any suggestions about that, i'd like to hear it. maybe this IS correct way, and i just dont know how to retrieve it and make it equal to $config['total_rows'] parameter.
[eluser]Herb[/eluser]
Sorry. Misunderstood the problem. http://www.techonthenet.com/sql/count.php Code: "SELECT count(*) as my_count FROM ......." You confused me with all the code. |
Welcome Guest, Not a member yet? Register Sign In |