Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,199,200 members, 7,970,741 topics. Date: Wednesday, 09 October 2024 at 02:38 PM |
Nairaland Forum / Science/Technology / Programming / Please Help Me In This PHP Pagination Code (1121 Views)
Create A Todo App With React, Node JS And Mysql Using Sequelize And Pagination / This Php Server Remote Addr Is Giving Me Different Device Ip Address / Jquery Pagination Plugin (2) (3) (4)
Please Help Me In This PHP Pagination Code by Falisto: 6:40pm On Aug 05, 2018 |
Hi, Good Nairaland programmers, I want you to help me in this PHP pagination code. It is always giving out error message whenever i click at the next link. please help me to look at it and help me to make corrections. Thanks. The code is here below: <?php // Get the search variable from URL if(isset($_POST['SUBMIT'])){ $professionals = $_POST['profession']; $country = $_POST['country']; } elseif(isset($_GET['_xp'],$_GET['_xs'])){ $professionals = $_GET['_xp']; $country = $_GET['_xs']; } // rows to return $limit=10; $professionals = $_POST['profession']; $country = $_POST['country']; //connect to your database ** EDIT REQUIRED HERE ** $conn = mysql_connect("localhost","profes13_members","notebook8a1c" $db = mysql_select_db("profes13_list", $conn); //specify database ** EDIT REQUIRED HERE ** // Build SQL Query $s = (isset($_GET['s']))? $_GET['s']:0; $query = "select * from members where profession ='$professionals' order by RAND() "; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "your search returned zero result<br>"; echo"<a href = 'memberusage.php'>CONTINUE SEARCH HERE</A>"; } // next determine if s has been passed to script, if not use 0 $s = (isset($_GET['s']))? $_GET['s']:0; // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query" // display what the person searched for // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $username = $row["username"]; $name =$row['name']; $gender =$row['gender']; $profession = $row['profession']; $pics = $row['pics']; $num = "($count )"; echo $num; ?> <img src= "<?php echo $pics; ?>" alt="Nigerian Directory of Professionals" width="70" height="70" /><br /> <b>Name</b>::<b><font color="#009933"> <?php echo $name ?></font></b><br /> <?php echo "<a href='profile.php?id=" . $username . "'> "."".""." View $name's profile </a><br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo " <br />" ; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"" . $_SERVER['PHP_SELF'] . "?s=$prevs&_xp\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"" . $_SERVER['PHP_SELF'] . "?s=$news&_xp\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> |
Re: Please Help Me In This PHP Pagination Code by dragnet: 6:49pm On Aug 05, 2018 |
post the errors you're getting, those who want to help you can interprete and make corrections or suggestions. |
Re: Please Help Me In This PHP Pagination Code by Bolaji21(m): 5:01pm On Aug 06, 2018 |
For starters, change from mysql to mysqli, it'll most likely not work cos it's been depreciated in php 5 and removed in php 7. Secondly, try to adapt this pagination function to your taste function pagination ($con,$page_id,$query,$ppage=20) |
Re: Please Help Me In This PHP Pagination Code by Falisto: 6:41pm On Aug 08, 2018 |
Ok. Ill try it. Thanks. |
Re: Please Help Me In This PHP Pagination Code by Ayemileto(m): 12:48pm On Aug 09, 2018 |
What's the exact error you are getting? |
(1) (Reply)
Bulk Whatsapp Message Sender / Share How You Develop/get App Ideas? / What Should We Do To Compete With Nairaland Website
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 35 |