php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6171 my next button link is not working, to link the next page
Submitted: 2000-08-15 11:46 UTC Modified: 2005-03-31 16:13 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: martinkuria at hotmail dot com Assigned:
Status: Wont fix Package: PostgreSQL related
PHP Version: 3.0.16 OS: Linux 6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martinkuria at hotmail dot com
New email:
PHP Version: OS:

 

 [2000-08-15 11:46 UTC] martinkuria at hotmail dot com
hi there, I would like to display my data from my postgresql database on my html file but
the data is alot to be display on one page so I want to display it on several pages,
so am using next to link to the next page to view the data, but when I click next, or
one of the links it does not display from the specified row, please assist on this
thanks.

best regards
Martin Kuria
below is my code
please assist,.

<html>
<body>
<?php
 $conn = pg_connect( "host=localhost user=postgres password=martinmw dbname=kenyellowpages");

  if (!$conn) {
     echo  "An error occured.\n";
     exit;
  }

 

$sql_text= "SELECT * FROM orgdetails1 
                                WHERE 
                                     lower(orgname) LIKE lower('$orgname%') AND 
                                     lower(catparent) LIKE lower('$catparent%') AND 
                                     lower(cityid) LIKE '$cityid%';";

$per_page = 5;   

  if (!$page) {  
      $page = 1;  
  }  
 
  $prev_page = $page - 1;  
  $next_page = $page + 1; 
  
  //$query = mysql_query($sql_text); 
    $result_set = pg_Exec($conn, $sql_text);

  //Set up specified page  
    $page_start = ($per_page + $page) - $per_page;  

  //$num_rows = mysql_num_rows($query);  
    $num_rows = pg_NumRows($result_set);

  if ($num_rows <= $per_page) {  
    $num_pages = 1;  
  } 

  else if (($num_rows % $per_page) == 0) {  
    $num_pages = ($num_rows / $per_page);  
  }

  else {  
    $num_pages = ($num_rows / $per_page) + 1;  
  }
  
   $num_pages = (int) $num_pages;  

  if (($page > $num_pages) || ($page < 0)) {  
    error("You have specified an invalid page number");  
  }  
 
  // Now the pages are set right, we can  
 // perform the actual displaying...  
   $sql_text1= "SELECT * FROM orgdetails1 
                                   WHERE 
                                     lower(orgname) LIKE lower('$orgname%') AND 
                                     lower(catparent) LIKE lower('$catparent%') AND 
                                     lower(cityid) LIKE '$cityid%' limit $page_start,$per_page;";

  //$sql_text = $sql_text." LIMIT $page_start,$per_page ";  
 //$query = mysql_query($sql_text); 
   $result_set1 = pg_Exec($conn, $sql_text);
   $num_rows1 = pg_NumRows($result_set1);

for ($j=0; $j < $num_rows1; $j++) {
$pos = pg_result($result_set, $j,  "orgname");
$pos2 = pg_result($result_set, $j,  "postadd");
$pos3 = pg_result($result_set, $j,  "phadd");
$pos4 = pg_result($result_set, $j,  "tel");
$pos5 = pg_result($result_set, $j,  "fax");
$pos6 = pg_result($result_set, $j,  "email");
$pos7 = pg_result($result_set, $j,  "website");
$pos8 = pg_result($result_set, $j,  "cityid");
$pos9 = pg_result($result_set, $j,  "catid");
$pos10 = pg_result($result_set,$j,  "catparent");
$pos11 = pg_result($result_set,$j,  "id");

/*while ($result = pg_fetch_array($result_set1)) {  
     // This stuff is obviously just an example.  This is where you want 
     // to layout your HTML to display the queries.  This loop will run 
     // once for every entry to be displayed on the current page. 
     echo "$result[orgname]"; 
     echo "<br>";*/


echo  "<center>";
echo  "<table width=90% bgcolor=#ffffff cellpadding=0 cellspacing=2 border=0>";



echo  "<tr>
         <td align=Left BGCOLOR=#efefef colspan=3>
          <ul><li>
               <font size=-2 face=Verdana, Arial, Helvetica, sans-serif color=#000000>
                 <a href=yellowmustall.php3?id=$pos11&catid=$pos9>
                    $pos
                 </a>&nbsp;
               <font size=-2>$pos2</font>
             </li></ul>
        </td>
       </tr></table></center>";


}


// Previous  
 if ($prev_page)  { 
    echo "<a href=\"$PHP_SELF?page=$prev_page&cityid=$pos8&catid=$pos9&catparent=$pos10\">Prev</a> "; 
 } 

 // Page # direct links  
 // If you don't want direct links to each page, you should be able to 
 // safely remove this chunk. 
 for ($i = 1; $i <= $num_pages; $i++) {  

      if ($i != $page) {  
          echo " <a href=\"$PHP_SELF?page=$i&cityid=$pos8&catid=$pos9&catparent=$pos10\">$i</a> ";  
      } 

          else {  
             echo " $i ";  
          }  
 }  

 // Next  
    if ($page != $num_pages) {  
        echo "<a href=\"$PHP_SELF?page=$next_page&cityid=$pos8&catid=$pos9&catparent=$pos10\">Next</a>";  
    } 

    ?> 
</body></html>






Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-15 11:49 UTC] joey@php.net
Dup: #6172
 [2005-03-31 16:13 UTC] php-bugs at lists dot php dot net
We are sorry, but we do not support PHP 3 related problems anymore.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 23 19:01:26 2020 UTC