myrok24 Posted January 20, 2009 Share Posted January 20, 2009 PLease can someone help me with my issue. I have this pagination in my file. But somehow it's not getting the right values or something for the next, previous e hyperlinks... my code: <? if (isset($_GET['pagina'])) { $pagina = $_GET['pagina']; } else { $pagina = 1; } $query = "SELECT count(*) FROM upload WHERE klant = '".mysql_real_escape_string($_GET['klant'])."' "; $result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $pagina = (int)$pagina; if ($pagina > $lastpage) { $pagina = $lastpage; } if ($pagina < 1) { $pagina = 1; } $limit = 'LIMIT ' .($pagina - 1) * $rows_per_page .',' .$rows_per_page; $query = " SELECT id, name, label, tekst, category, klant, DATE_FORMAT(datum, '%d-%m-%Y') AS nl_datum FROM upload WHERE klant = '".mysql_real_escape_string($_GET['klant'])."' $limit"; $result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR); while ($myrow = mysql_fetch_assoc($result)) { ?> <!-- ### WERK TONEN ######--> <div style="width:500px;background-color:#0CF; float:right"> <div > <div> <h3> <? echo $myrow['klant'] ?></h3> <p class="newsdate">Geplaatst op: <? echo $myrow['nl_datum'] ?></p> <p class="newsdate">Middel: <? echo $myrow['category'] ?></p> <p class="newsdate">Opdracht: <? echo $myrow['label'] ?></p> <? echo '<img class=plaatje src="image/' . $myrow['name'] . '" />' ; ?> <p class="newstext"> <? echo ($myrow['tekst']) ?> </p> </div> </div> </div> <?php } // (else..) aflsuiten.. ?> <? if ($pagina == 1) { echo " EERSTE VORIGE"; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagina=1'>EERSTE</a> "; $prevpage = $pagina-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagina=$prevpage'>VORIGE</a> "; } echo " ( pagina $pagina / $lastpage ) "; if ($pagina == $lastpage) { echo " VOLGENDE LAATSTE "; } else { $nextpage = $pagina+1; // echo " <a href='{$_SERVER['PHP_SELF']}?pagina=$nextpage'>VOLGENDE</a> "; echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&pagina=$nextpage'>VOLGENDE</a> "; ?> //new one.. echo " <a href='{$_SERVER['PHP_SELF']}?pagina=$lastpage'>LAATSTE</a> "; } ?> I changed one "next" hyperlink with a better url. but still nothing in the output when i click it. Strange thing is that the total record count is correct and when i changed the max resultst, the records are al there. So the only thing that's not working are the buttons for more.. It's not getting the right info?.. thnx in advance! example: http://blikvoer.com/temp/samtest/index.php?pagina=klanten&klant=Anwb --> second "volgende" link.. Link to comment https://forums.phpfreaks.com/topic/141615-solved-pagination-no-next-result/ Share on other sites More sharing options...
cytech Posted January 20, 2009 Share Posted January 20, 2009 Hey there, You have the right idea here: echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&pagina=$nextpage'>VOLGENDE</a> "; ?> Just update it to: echo " <a href='index.php?klant={$_GET['klant']}&pagina=$nextpage'>VOLGENDE</a> "; ?> Also be sure to put the klant={$_GET['klant']} on all of your pagination links. Link to comment https://forums.phpfreaks.com/topic/141615-solved-pagination-no-next-result/#findComment-741241 Share on other sites More sharing options...
myrok24 Posted January 20, 2009 Author Share Posted January 20, 2009 No thats not it maybe it's bit confusion because.. there's another "pagina". wich is the current page (pagina=klanten.php). Somehow its;s not giving any result in the next page.. dunno if the "GET" argument is good also.. Link to comment https://forums.phpfreaks.com/topic/141615-solved-pagination-no-next-result/#findComment-741332 Share on other sites More sharing options...
myrok24 Posted January 20, 2009 Author Share Posted January 20, 2009 solved.. final code: <? if (isset($_GET['selectie'])) { $selectie = $_GET['selectie']; } else { $selectie = 1; } $query = "SELECT count(*) FROM upload WHERE klant = '".mysql_real_escape_string($_GET['klant'])."' "; $result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 1; $lastpage = ceil($numrows/$rows_per_page); $selectie = (int)$selectie; if ($selectie > $lastpage) { $selectie = $lastpage; } if ($selectie < 1) { $selectie = 1; } $limit = 'LIMIT ' .($selectie - 1) * $rows_per_page .',' .$rows_per_page; $query = " SELECT id, name, label, tekst, category, klant, DATE_FORMAT(datum, '%d-%m-%Y') AS nl_datum FROM upload WHERE klant = '".mysql_real_escape_string($_GET['klant'])."' $limit "; $result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR); while ($myrow = mysql_fetch_assoc($result)) { ?> <!-- ### WERK TONEN ######--> <div style="width:500px;background-color:#0CF; float:right"> <div > <div> <h3> <? echo $myrow['klant'] ?></h3> <p class="newsdate">Geplaatst op: <? echo $myrow['nl_datum'] ?></p> <p class="newsdate">Middel: <? echo $myrow['category'] ?></p> <p class="newsdate">Opdracht: <? echo $myrow['label'] ?></p> <? echo '<img class=plaatje src="image/' . $myrow['name'] . '" />' ; ?> <p class="newstext"> <? echo ($myrow['tekst']) ?> </p> </div> </div> </div> <!-- ### PAGINERING: volgende/totaal/volgende ######--> <div style="background-color:yellow"> <? if ($selectie == 1) { echo "<FONT color=grey size=1>VORIGE</FONT>"; //tekst als er geen vorige of eerste is } else { // echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&selectie=1'> <FONT size=1>EERSTE</FONT></a> "; //eerste optie $prevpage = $selectie-1; echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&selectie=$prevpage'><FONT size=1>VORIGE</FONT></a> "; //vorige optie } echo " <FONT size=1> || OPDRACHT <strong> $selectie </strong> / $lastpage || </FONT> "; if ($selectie == $lastpage) { echo "<FONT color=grey size=1>VOLGENDE</FONT>"; //tekst als er geen volgende of laatste is } else { $nextpage = $selectie+1; echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&selectie=$nextpage'><FONT size=1>VOLGENDE</FONT></a> "; //volgende optie // echo " <a href='index.php?pagina=klanten&klant={$_GET['klant']}&selectie=$lastpage'><FONT size=1>LAATSTE</FONT></a> "; //laatste optie } ?></br>KLANTEN </div> <!-- ### PAGINERING EINDE ####--> <?php } // (while..) aflsuiten.. ?> Link to comment https://forums.phpfreaks.com/topic/141615-solved-pagination-no-next-result/#findComment-741480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.