i've added the $_SERVER['php_self'] but it still displayed the message undefine $php_self. i want to implement the pagination code but it failed. i would be very glad if someone could help me to solve this problem.here is the sample of my code.
<?
mysql_connect("localhost","root",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("e-library") or die("Unable to select database"); //select which database we're using
$search = isset($_GET['search'])? $_GET['search']:"" ;
$group = isset($_GET['group'])? $_GET['group']:"";
$limit=10;
$count = 1;
if ($search == "")
{
$query = "select * from book"; // EDIT HERE and specify your table and field names for the SQL query
}
if ($search != "" && $group == "all")
{
$query = "select * from book where author like '%$search%' or category like '%$search%' or edition like '%$search%' or ISBN like '%$search%' or publisher like '%$search%' or title like '%$search%' or year like '%$search%'"; // EDIT HERE and specify your table and field names for the SQL query
}
if($search != "" && $group == "author")
{
$query = "select * from book where author like '%$search%'";
}
if($search != "" && $group == "category")
{
$query = "select * from book where category like '%$search%'";
}
if($search != "" && $group == "edition")
{
$query = "select * from book where edition like '%$search%'";
}
if($search != "" && $group == "ISBN")
{
$query = "select * from book where ISBN like '%$search%'";
}
if($search != "" && $group == "publisher")
{
$query = "select * from book where publisher like '%$search%'";
}
if($search != "" && $group == "title")
{
$query = "select * from book where title like '%$search%'";
}
if($search != "" && $group == "year")
{
$query = "select * from book where year like '%$search%'";
}
$numresults=mysql_query($query) or die("x tahu");
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<tr><td>";
echo "<h4>Results</h4>";
echo "<p>Sorry,the data are not in database</p>";
echo "</td></tr>";
}
else
{
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result))
{
$title = $row['title'];
$ISBN = $row['ISBN'];
$abstract = $row['description'];
echo "$count. <a href=\"View_Book.php?ref=$ISBN\">$title</a>" ;
?>
<img src="Image/nw2.gif" onclick="MM_openBrWindow('View_Book.php?ref=<? echo $ISBN;?>','','')" >
<?
echo "<br>";
echo myfragment($abstract, 150);
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&search=$search&group=$group\"><<
Prev</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&search=$search&group=$group\">Next>></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
echo "<br> "; }?></td>
thanks in advance..
<?
mysql_connect("localhost","root",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("e-library") or die("Unable to select database"); //select which database we're using
$search = isset($_GET['search'])? $_GET['search']:"" ;
$group = isset($_GET['group'])? $_GET['group']:"";
$limit=10;
$count = 1;
if ($search == "")
{
$query = "select * from book"; // EDIT HERE and specify your table and field names for the SQL query
}
if ($search != "" && $group == "all")
{
$query = "select * from book where author like '%$search%' or category like '%$search%' or edition like '%$search%' or ISBN like '%$search%' or publisher like '%$search%' or title like '%$search%' or year like '%$search%'"; // EDIT HERE and specify your table and field names for the SQL query
}
if($search != "" && $group == "author")
{
$query = "select * from book where author like '%$search%'";
}
if($search != "" && $group == "category")
{
$query = "select * from book where category like '%$search%'";
}
if($search != "" && $group == "edition")
{
$query = "select * from book where edition like '%$search%'";
}
if($search != "" && $group == "ISBN")
{
$query = "select * from book where ISBN like '%$search%'";
}
if($search != "" && $group == "publisher")
{
$query = "select * from book where publisher like '%$search%'";
}
if($search != "" && $group == "title")
{
$query = "select * from book where title like '%$search%'";
}
if($search != "" && $group == "year")
{
$query = "select * from book where year like '%$search%'";
}
$numresults=mysql_query($query) or die("x tahu");
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<tr><td>";
echo "<h4>Results</h4>";
echo "<p>Sorry,the data are not in database</p>";
echo "</td></tr>";
}
else
{
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result))
{
$title = $row['title'];
$ISBN = $row['ISBN'];
$abstract = $row['description'];
echo "$count. <a href=\"View_Book.php?ref=$ISBN\">$title</a>" ;
?>
<img src="Image/nw2.gif" onclick="MM_openBrWindow('View_Book.php?ref=<? echo $ISBN;?>','','')" >
<?
echo "<br>";
echo myfragment($abstract, 150);
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&search=$search&group=$group\"><<
Prev</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&search=$search&group=$group\">Next>></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
echo "<br> "; }?></td>
thanks in advance..






