I am pulling data from a MySQL database and displaying them on a page. I am breaking it in pages. I have this code where Sonraki (Next) link should give me next page but instead it just adds another &sayfano=1 the URL. Can you help me in this? Regards,
not sure, but your using
$prev = $sayfano - 1;
but you use
$next = $pagenum + 1;
Didnt see a $pagenum in there, but then again it was just a quick scroll trough.
ah yeah, the reason why your url looks similar to this www.example.com?sayfano=1&sayfano=1&sayfano=1&sayfano=1&sayfano=1
is that your including $_SERVER['QUERY_STRING'] in the link without checking if sayfano is already a part of the query string
ah yeah, the reason why your url looks similar to this www.example.com?sayfano=1&sayfano=1&sayfano=1&sayfano=1&sayfano=1
is that your including $_SERVER['QUERY_STRING'] in the link without checking if sayfano is already a part of the query string
it doesnt go to page 2 because your not using the _GET variable. instead your setting the current page to 1 here
[color=#000000]if (!(isset($sayfano))) { $sayfano = 1; }
$sayfano wont be set at this point since your not declaring it.
insert $sayfano = $_GET['sayfano']; before the if.
Quote:
Originally Posted by tolga
How do I check that?
you can remove it completely with something similar to (untested)
you cant see the previous page links because the condition for these to show is that your on he last page.
if ($sayfano == $last) {}
else {
$next = $pagenum + 1;
Abolut the tutorial:
its good overall, however there are a few problems with the tutorial.
firstly,
$totalpages = round($total / $perpage);
if you have 54 users in the database, 10 per page, you get 5.4 pages, which will round to 5. you will never be able to see the last 4 users because your using round and not ceil().
Another thing that i noticed was that you use the same query for counting and selecting but you still execute it twice, which is a waste. num_rows is probably the best way on innoDB based mysql tables but "SELECT COUNT(*)" is significantly faster on MyISAM based tables, which i belive is the default one.
you cant see the previous page links because the condition for these to show is that your on he last page.
if ($sayfano == $last) {}
else {
$next = $pagenum + 1;
I never said I couldn't see the previous page links, but you are right I can't. What I said was Sonraki (Next) link goes to page 2 only.