Hi i found this script from google search (PHPSense) on pagination. It's a wonderful script. However i wasnt able to do search query on this script. Can anyone help me to figure out how i should go about to modify this script if my search query contains WHEREBY field LIKES %$val_a%.

<?php
	//Include the PS_Pagination class
	include('ps_pagination.php');
	
	//Connect to mysql db
	$conn = mysql_connect('localhost','jatinder','secret');
	if(!$conn) die("Failed to connect to database!");
	$status = mysql_select_db('database', $conn);
	if(!$status) die("Failed to select database!");
	$sql = 'SELECT * FROM sometable';
	
	/*
	 * Create a PS_Pagination object
	 * 
	 * $conn = MySQL connection object
	 * $sql = SQl Query to paginate
	 * 10 = Number of rows per page
	 * 5 = Number of links
	 * "param1=valu1&param2=value2" = You can append your own parameters to paginations links
	 */
	$pager = new PS_Pagination($conn, $sql, 10, 5, "param1=valu1&param2=value2");
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());
	while($row = mysql_fetch_assoc($rs)) {
		echo $row['image'],"<br />\n";
	}
	
	//Display the full navigation in one go
	echo $pager->renderFullNav();
	
	echo "<br />\n";
	
	/*
	 * Or you can display the individual links for more
	 * control over HTML rendering.
	 * 
	*/
	
	//Display the link to first page: First
	echo $pager->renderFirst();
	
	//Display the link to previous page: <<
	echo $pager->renderPrev();
	
	/*
	 * Display page links: 1 2 3
	 * $prefix = Will be prepended to the page link (optional)
	 * $suffix = Will be appended to the page link (optional)
	 * 
	*/
	echo $pager->renderNav('<span>', '</span>');
	
	//Display the link to next page: >>
	echo $pager->renderNext();
	
	//Display the link to last page: Last
	echo $pager->renderLast();
?>
<?php
/**
 * PHPSense Pagination Class
 *
 * PHP tutorials and scripts
 *
 * @package		PHPSense
 * @author		Jatinder Singh Thind
 * @copyright	Copyright (c) 2006, Jatinder Singh Thind
 * @link		http://www.phpsense.com
 */

// ------------------------------------------------------------------------


class PS_Pagination {
	var $php_self;
	var $rows_per_page = 20; //Number of records to display per page
	var $total_rows = 0; //Total number of rows returned by the query
	var $links_per_page = 5; //Number of links to display per page
	var $append = ""; //Paremeters to append to pagination links
	var $sql = "";
	var $debug = false;
	var $conn = false;
	var $page = 1;
	var $max_pages = 0;
	var $offset = 0;
	
	/**
	 * Constructor
	 *
	 * @param resource $connection Mysql connection link
	 * @param string $sql SQL query to paginate. Example : SELECT * FROM users
	 * @param integer $rows_per_page Number of records to display per page. Defaults to 10
	 * @param integer $links_per_page Number of links to display per page. Defaults to 5
	 * @param string $append Parameters to be appended to pagination links 
	 */
	
	function PS_Pagination($connection, $sql, $rows_per_page = 20, $links_per_page = 5, $append = "") {
		$this->conn = $connection;
		$this->sql = $sql;
		$this->rows_per_page = (int)$rows_per_page;
		if (intval($links_per_page ) > 0) {
			$this->links_per_page = (int)$links_per_page;
		} else {
			$this->links_per_page = 5;
		}
		$this->append = $append;
		$this->php_self = htmlspecialchars($_SERVER['PHP_SELF'] );
		if (isset($_GET['page'] )) {
			$this->page = intval($_GET['page'] );
		}
	}
	
	/**
	 * Executes the SQL query and initializes internal variables
	 *
	 * @access public
	 * @return resource
	 */
	function paginate() {
		//Check for valid mysql connection
		if (! $this->conn || ! is_resource($this->conn )) {
			if ($this->debug)
				echo "MySQL connection missing<br />";
			return false;
		}
		
		//Find total number of rows
		$all_rs = @mysql_query($this->sql );
		if (! $all_rs) {
			if ($this->debug)
				echo "SQL query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
			return false;
		}
		$this->total_rows = mysql_num_rows($all_rs );
		@mysql_close($all_rs );
		
		//Return FALSE if no rows found
		if ($this->total_rows == 0) {
			if ($this->debug)
				echo "Query returned zero rows.";
			return FALSE;
		}
		
		//Max number of pages
		$this->max_pages = ceil($this->total_rows / $this->rows_per_page );
		if ($this->links_per_page > $this->max_pages) {
			$this->links_per_page = $this->max_pages;
		}
		
		//Check the page value just in case someone is trying to input an aribitrary value
		if ($this->page > $this->max_pages || $this->page <= 0) {
			$this->page = 1;
		}
		
		//Calculate Offset
		$this->offset = $this->rows_per_page * ($this->page - 1);
		
		//Fetch the required result set
		$rs = @mysql_query($this->sql . " LIMIT {$this->offset}, {$this->rows_per_page}" );
		if (! $rs) {
			if ($this->debug)
				echo "Pagination query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
			return false;
		}
		return $rs;
	}
	
	/**
	 * Display the link to the first page
	 *
	 * @access public
	 * @param string $tag Text string to be displayed as the link. Defaults to 'First'
	 * @return string
	 */
	function renderFirst($tag = 'First') {
		if ($this->total_rows == 0)
			return FALSE;
		
		if ($this->page == 1) {
			return "$tag ";
		} else {
			return '<a href="' . $this->php_self . '?page=1&' . $this->append . '">' . $tag . '</a> ';
		}
	}
	
	/**
	 * Display the link to the last page
	 *
	 * @access public
	 * @param string $tag Text string to be displayed as the link. Defaults to 'Last'
	 * @return string
	 */
	function renderLast($tag = 'Last') {
		if ($this->total_rows == 0)
			return FALSE;
		
		if ($this->page == $this->max_pages) {
			return $tag;
		} else {
			return ' <a href="' . $this->php_self . '?page=' . $this->max_pages . '&' . $this->append . '">' . $tag . '</a>';
		}
	}
	
	/**
	 * Display the next link
	 *
	 * @access public
	 * @param string $tag Text string to be displayed as the link. Defaults to '>>'
	 * @return string
	 */
	function renderNext($tag = '&gt;&gt;') {
		if ($this->total_rows == 0)
			return FALSE;
		
		if ($this->page < $this->max_pages) {
			return '<a href="' . $this->php_self . '?page=' . ($this->page + 1) . '&' . $this->append . '">' . $tag . '</a>';
		} else {
			return $tag;
		}
	}
	
	/**
	 * Display the previous link
	 *
	 * @access public
	 * @param string $tag Text string to be displayed as the link. Defaults to '<<'
	 * @return string
	 */
	function renderPrev($tag = '&lt;&lt;') {
		if ($this->total_rows == 0)
			return FALSE;
		
		if ($this->page > 1) {
			return ' <a href="' . $this->php_self . '?page=' . ($this->page - 1) . '&' . $this->append . '">' . $tag . '</a>';
		} else {
			return " $tag";
		}
	}
	
	/**
	 * Display the page links
	 *
	 * @access public
	 * @return string
	 */
	function renderNav($prefix = '<span class="page_link">', $suffix = '</span>') {
		if ($this->total_rows == 0)
			return FALSE;
		
		$batch = ceil($this->page / $this->links_per_page );
		$end = $batch * $this->links_per_page;
		if ($end == $this->page) {
			//$end = $end + $this->links_per_page - 1;
		//$end = $end + ceil($this->links_per_page/2);
		}
		if ($end > $this->max_pages) {
			$end = $this->max_pages;
		}
		$start = $end - $this->links_per_page + 1;
		$links = '';
		
		for($i = $start; $i <= $end; $i ++) {
			if ($i == $this->page) {
				$links .= $prefix . " $i " . $suffix;
			} else {
				$links .= ' ' . $prefix . '<a href="' . $this->php_self . '?page=' . $i . '&' . $this->append . '">' . $i . '</a>' . $suffix . ' ';
			}
		}
		
		return $links;
	}
	
	/**
	 * Display full pagination navigation
	 *
	 * @access public
	 * @return string
	 */
	function renderFullNav() {
		return $this->renderFirst() . '&nbsp;' . $this->renderPrev() . '&nbsp;' . $this->renderNav() . '&nbsp;' . $this->renderNext() . '&nbsp;' . $this->renderLast();
	}
	
	/**
	 * Set debug mode
	 *
	 * @access public
	 * @param bool $debug Set to TRUE to enable debug messages
	 * @return void
	 */
	function setDebug($debug) {
		$this->debug = $debug;
	}
}
?>

this code works well with the search query only on the 1st page but the post value is erased when you click the next page . Hoping someone can help me with this. Cheers

this code works well with the search query only on the 1st page but the post value is erased when you click the next page . Hoping someone can help me with this. Cheers

hi i think you didn't pass your search string and total no of rows to ps_paginagation class. pass them and try.

Im not too sure how to do it as this code was downloaded from a site. Im not very familiar with this type of coding. Would you be able to assist me on this? Thanks for your help.

Im not too sure how to do it as this code was downloaded from a site. Im not very familiar with this type of coding. Would you be able to assist me on this? Thanks for your help.

i have another paginagation script .

i have another paginagation script .

Do you think i can have a look at your pagination script ?

Im not too sure how to do it as this code was downloaded from a site. Im not very familiar with this type of coding. Would you be able to assist me on this? Thanks for your help.

exmple.php

<? 
ob_start();
session_start();
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("paginagation.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="shawl, floral  design shawl, printed shawl, geometric design shawl, bandana, schal, scarves, foulard" />
<title>example</title>

</head>

<body>

<div id="wrapper">
<div id="wrapper2">

  <!--Top Shadow starts here-->
  <div class="top_shadow"></div>
  <!--Top Shadow ends here-->
  
  <!--center Shadow starts here-->
  <div class="center_shadow">
  
    <div class="main_border">
    
    <!--Top banner starts here-->
      <? include("includes/header.php"); ?>
    <!--Top banner ends here-->
    
    <!--main container starts here-->
    <div class="main_container">
      
    <? include("includes/leftpanel.php");  ?>
      
      <div class="right_main">
        <div class="right_panel">
		  
<div class="inner_product2">
<?
    $count=0;
	
	$user1=mysql_query("your query");
	    $sqlitem=mysql_query("your query) ORDER BY auto_id DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$no_items=mysql_num_rows($sqlitem);
	if($no_items>0)
	{
	while($sqlfetchitem=mysql_fetch_array($sqlitem))
    {
	?>	
"your diaplay items"
<?
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  }
  }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
</ul>

</div>
<div  align="right">


<span class="normal_text_light">
                <?  
				paginate($start,$q_limit,$no_rows,$filePath,$otherParams);?>
              </span>

</div>
	  

              

              
          </div>
      </div>
      </div>
      
    
      
      
      </div>
    <!--main container ends here-->
      
    </div>
  </div>
  <!--center Shadow ends here-->
  

</div>
</div>
</body>
</html>

paginagation.php

function paginate($start,$limit,$total,$filePath,$otherParams) {
	global $lang;

	$allPages = ceil($total/$limit);

	$currentPage = floor($start/$limit) + 1;

	$pagination = "";
	if ($allPages>10) {
		$maxPages = ($allPages>9) ? 9 : $allPages;

		if ($allPages>9) {
			if ($currentPage>=1&&$currentPage<=$allPages) {
				$pagination .= ($currentPage>4) ? " ... " : " ";

				$minPages = ($currentPage>4) ? $currentPage : 5;
				$maxPages = ($currentPage<$allPages-4) ? $currentPage : $allPages - 4;

				for($i=$minPages-4; $i<$maxPages+5; $i++) {
					$pagination .= ($i == $currentPage) ? "[".$i."] " : "<a class='linktext' href=\"".$filePath."?start=".(($i-1)*$limit).$otherParams."\">".$i."</a> ";
				}
				$pagination .= ($currentPage<$allPages-4) ? " ... " : " ";
			} else {
				$pagination .= " ... ";
			}
		}
	} else {
		for($i=1; $i<$allPages+1; $i++) {
			$pagination .= ($i==$currentPage) ? "[".$i."] " : "<a class='linktext' href=\"".$filePath."?start=".(($i-1)*$limit).$otherParams."\">".$i."</a> ";
		}
	}

	if ($currentPage>1) $pagination = "[<a class='linktext' href=\"".$filePath."?start=0".$otherParams."\">&lt;&lt;</a>] [<a  class='linktext' href=\"".$filePath."?start=".(($currentPage-2)*$limit).$otherParams."\">&lt;</a>] ".$pagination;
	if ($currentPage<$allPages) $pagination .= " [<a class='linktext' href=\"".$filePath."?start=".($currentPage*$limit).$otherParams."\">&gt;</a>] [<a class='linktext' href=\"".$filePath."?start=".(($allPages-1)*$limit).$otherParams."\">&gt;&gt;</a>]";

	echo $pagination;
}

try this one.

sure.. i'll have a look and give it a try. get back to you should i have any problem arise..
Cheers mate :)

exmple.php
try this one.

Hi. after modifying from your script, i can only view the pagination display but my results are not display out. will you be able to simplify it?

Hi I found another code and m using this one. kinda simple. but again i wasnt able to get my 2nd page to work when i pass my search query. I understand that i have to do something with the passing search query, but i don't really know where i should go about.

$val_d = $_POST['device_search'];

if ($_POST['SEARCH'] = 'Device Search')
{
	$sql = "SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d'"; 
	$results1 = mysql_query($sql) or die (mysql_error());	
	
			$pagenum = $_GET["pagenum"];
			echo "<center>";
			//This checks to see if there is a page number. If not, it will set it to page 1 
			if (!(isset($pagenum))) 
			{ 
			$pagenum = 1; 
			} 

	$numrows = mysql_num_rows($results1);		
	$page_rows = 10; //This is the number of results displayed per page 
	$last = ceil($numrows/$page_rows); //This tells us the page number of our last page 
	if ($pagenum < 1) //this makes sure the page number isn't below one, or more than our maximum pages 
	{ 
	$pagenum = 1; 
	} 
	elseif ($pagenum > $last) 
	{ 
	$pagenum = $last; 
	} 

	$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This sets the range to display in our query 
				
	$sql = "SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d' $max"; 
	$results = mysql_query($sql) or die (mysql_error());
 
	//$count = mysql_result($results,0,0);
	//echo "<b></center>Record Count: </b> $count record(s)<br><br><center>";

	include "FTsearchtable.php";
	
	echo "<br><br><center>Page $pagenum of $last<br><br>"; // This shows the user what page they are on, and the total number of pages

	// First we check if we are on page one. 
	//If we are then we don't need a link to the previous page or the first page so we do nothing. 
	//If we aren't then we generate links to the first page, and to the previous page.
	if($pagenum>1)
	{

	echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'>First</a> ";
	$previous = $pagenum-1;
	echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'>Previous</a> ";
	} 
	//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
	if ($pagenum == $last) 
	{
	} 
	else 
	{
	$next = $pagenum+1;
	echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next</a> ";
	echo " ";
	echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last</a> ";
	} 
	
	}

Hi. after modifying from your script, i can only view the pagination display but my results are not display out. will you be able to simplify it?

post ur modified script i will see it .

Im not sure if i did it correctly.. but here's the code i modify.

example.php

<?php
include "header.php"; // my sql connection
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("pagination.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];

?>

<html>
<head>
<title>example</title>

</head>

<body>

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
			FROM device");
	   $sqlitem=mysql_query("SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d'
			ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$no_items=mysql_num_rows($sqlitem);
	if($no_items>0)
	{	
	while($sqlfetchitem=mysql_fetch_array($sqlitem))
	{
	include "FTsearchtable.php";  // this is where my results are display
	}}
	?>	

<?php
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
<span class="normal_text_light">
                <?php
				paginate($start,$q_limit,$no_rows,$filePath,$otherParams);?>
              </span>

</body>
</html>

As for the pagination.php, it remains unchange.
Thanks

$sqlitem=mysql_query("SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'
ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");

is it working? why bcoz there is

ORDER BY device_id ORDER BY auto_id DESC

. how it is possible?

$user1=mysql_query("SELECT *
FROM device");
$sqlitem=mysql_query("SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'
ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");
$no_rows=mysql_num_rows($user1);
$no_items=mysql_num_rows($sqlitem);

write like this

$user1=mysql_query("SELECT *
			FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d'");
	   $sqlitem=mysql_query("SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d'
			ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
if($no_rows>0)

Im not sure if i did it correctly.. but here's the code i modify.

example.php

<?php
include "header.php"; // my sql connection
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("pagination.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];

?>

<html>
<head>
<title>example</title>

</head>

<body>

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
			FROM device");
	   $sqlitem=mysql_query("SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d'
			ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$no_items=mysql_num_rows($sqlitem);
	if($no_items>0)
	{	
	while($sqlfetchitem=mysql_fetch_array($sqlitem))
	{
	include "FTsearchtable.php";  // this is where my results are display
	}}
	?>	

<?php
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
<span class="normal_text_light">
                <?php
				paginate($start,$q_limit,$no_rows,$filePath,$otherParams);?>
              </span>

</body>
</html>

As for the pagination.php, it remains unchange.
Thanks

#
$user1=mysql_query("SELECT *
FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
$sqlitem=mysql_query("SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'
ORDER BY device_id  DESC limit $start,$q_limit");

you must specified where condition in first query, so it will select all the matched rows. restrict no of per page in the second query dont use order by twice.

can you explain your problem . where do you display pagination (which file) you must write above code that page. exampler.php is your page.

include "FTsearchtable.php";  // this is where my results are display

display the rows. not include file. if you want display rercords in that page write script in FTsearchtable.php page.

$searchstring=$_REQUEST['searchstring'];

it is your seaching string.

Thank muralikalpana , As for the searchstring, what is it referring to? i have this notice :" Undefined index: searchstring at line5 and15" and "mysql_num_rows() expects parameter 1 to be resource" at line 37".

Thank muralikalpana , As for the searchstring, what is it referring to? i have this notice :" Undefined index: searchstring at line5 and15" and "mysql_num_rows() expects parameter 1 to be resource" at line 37".

see last post which is send by me use that code. after that any errors you will send back post.

1.
      <?php
      include "header.php"; // my sql connection
      extract($_REQUEST);
       extract($_POST);
      $devicesearch=$_REQUEST['devicesearch'];//your searching string(text). searchstring=devicesearch
     include("pagination.php");
      $q_limit =4;
      $errMsg = 0;
      if( isset($_GET['start']) ){
      $start = $_GET['start'];
      }else{
      $start = 0;
      }
      $filePath = "example.php";//this is where do you want display pagination page
      $otherParams="&devicesearch=".$_REQUEST['devicesearch'];//
searchstring=devicesearch
      ?>
     <html>
      <head>
     <title>example</title>
      </head>
    <body>
     <?php
     $count=0;
      $val_d = $_POST['devicesearch'];
      $user1=mysql_query("SELECT *
      FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d'");
      $sqlitem=mysql_query("SELECT *
      FROM device
      WHERE device_num LIKE '%$val_d%' or '%$val_d'
      ORDER BY device_id DESC limit $start,$q_limit");
      $no_rows=mysql_num_rows($user1);
      $no_items=mysql_num_rows($sqlitem);
      if($no_items>0)
      {
      while($sqlfetchitem=mysql_fetch_array($sqlitem))
      {
     include "FTsearchtable.php"; // display records here not file 
      }}
      ?>
      <?php
      $count++;
      if($count==3)
      {
      echo "&nbsp;<br>";
      $count=0;
      }
      else
      {
      echo"<div class='normal_text_light' align='right'><p> NO Items </p></div>";
       }
        ?>
        <span class="normal_text_light">
      <?php
      paginate($start,$q_limit,$no_rows,$filePath,$otherParams);?>
      </span>
           </body>
      </html>

see it once.
expain your pages clearly. where do you have search field and where do you want display records (which pages tell page name)

Thank muralikalpana , As for the searchstring, what is it referring to? i have this notice :" Undefined index: searchstring at line5 and15" and "mysql_num_rows() expects parameter 1 to be resource" at line 37".

$user1=mysql_query("SELECT *
			FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d'");
	   $sqlitem=mysql_query("SELECT *
			FROM device
			WHERE device_num LIKE '%$val_d%' or '%$val_d'
			ORDER BY device_id ORDER BY auto_id DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
if($no_rows>0)
{

use above code where these line are in your script. it will works fine.

Still got no display.. let me show u my full code for assistance.

example.php

include "header.php"; // my sql connection
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("pagination.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];

?>

<html>
<head>
<title>example</title>

</head>

<body>

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
	FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
	$sqlitem=mysql_query("SELECT *
	FROM device
	WHERE device_num LIKE '%$val_d%' or '%$val_d'
	ORDER BY device_id  DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$row=mysql_num_rows($sqlitem);
	if($row>0)
	{	
	include "FTsearchtable.php"; 

	}
	?>	

<?php
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
<span class="normal_text_light">
                <?php
	paginate $start,$q_limit,$no_rows,$filePath,$otherParams); ?>
              </span>

</body>
</html>

FTsearchtable.php

<h2><center>Device Review Database</center></h2>
		<table width='120%' border='1' cellpadding='1'
		cellspacing='1' align='center'>
               <tr>
		<th align='center'>Device Number</th>
		<th align='center'>Device Revision</th>
		<th align='center'>Device Site</th>
		<th align='center'>Device Platform</th>
		<th align='center'>Device DIB_ID</th>
		<th align='center'>Socket number</th>
		<th align='center'>Socket Type</th>
		<th align='center'>Socket Part Number</th>
		<th align='center'>Subcon Site</th>
		<th align='center'>Subcon name</th>
		<th align='center'>Remarks</th>
	</tr>	  
			
<?php		
while($sqlfetchitem=mysql_fetch_array($sqlitem))
{	
	 $device_num = $row['device_num'];
	 $device_rev = $row['device_rev'];
	 $device_site = $row['device_site'];
	 $device_platform = $row['device_platform'];
	 $device_dibid = $row['device_dibid'];
	 $socketnum = $row['socket_idnum'];
	 $device_socketID = $row['device_socketID'];
	 $device_subconID = $row['device_subconID'];
	 $device_remark = $row['device_remark'];
 
	$query_rev = "SELECT rev_label
				  FROM rev
				  WHERE rev_id = '$device_rev' ";
	$results_rev = mysql_query($query_rev)
		or die (mysql_error());
	$row_rev = mysql_fetch_array ($results_rev);
	//extract ($row_rev);
	$rev_label = $row_rev['rev_label']; 
	
		 
	$query_site = "SELECT site_type
				  FROM site
				  WHERE site_id = '$device_site' ";
	$results_site = mysql_query($query_site)
		or die (mysql_error());
	$row_site = mysql_fetch_array ($results_site);
	//extract ($row_site);
	$site_type = $row_site['site_type'];
	 
	 $query_platform = "SELECT platform_model
						FROM platform
						WHERE platform_id = '$device_platform' ";
	$results_platform = mysql_query($query_platform)
		or die (mysql_error());
	$row_platform = mysql_fetch_array ($results_platform);
	//extract ($row_platform);
	$platform_model = $row_platform['platform_model'];
	
	 
	$query_soc = "SELECT socket_type, socket_partno
				FROM socket
				WHERE socket_id = '$device_socketID' ";
	$results_soc = mysql_query($query_soc)
		or die (mysql_error());
	$row_soc = mysql_fetch_array ($results_soc);
	//extract ($row_soc);
	$sockettype = $row_soc['socket_type'];	
	$socketpartno = $row_soc['socket_partno'];
	 
	
	$query_sub = "SELECT subcon_site, subcon_name
				FROM subcon
				WHERE subcon_id = '$device_subconID' ";
	$results_sub = mysql_query($query_sub)
		or die (mysql_error());
	$row_sub = mysql_fetch_array ($results_sub);
	//extract ($row_sub);
	$subconsite = $row_sub['subcon_site'];
	$subconname = $row_sub['subcon_name'];	
	  
?>	 
	<tr>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_num ;			
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $rev_label ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $site_type ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $platform_model  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_dibid  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketnum  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $sockettype  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketpartno  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $subconsite  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $subconname  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="20%">
		<?php 	
				echo $device_remark  ;		
		?>
		</td>
	
<?php
}
?>

instead of

if($row>0)

{

include "FTsearchtable.php";

}

?>

use

if($no_rows>0)

{

include "FTsearchtable.php";

 

}?>

Still got no display.. let me show u my full code for assistance.

example.php

include "header.php"; // my sql connection
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("pagination.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];

?>

<html>
<head>
<title>example</title>

</head>

<body>

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
	FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
	$sqlitem=mysql_query("SELECT *
	FROM device
	WHERE device_num LIKE '%$val_d%' or '%$val_d'
	ORDER BY device_id  DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$row=mysql_num_rows($sqlitem);
	if($row>0)
	{	
	include "FTsearchtable.php"; 

	}
	?>	

<?php
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
<span class="normal_text_light">
                <?php
	paginate $start,$q_limit,$no_rows,$filePath,$otherParams); ?>
              </span>

</body>
</html>

FTsearchtable.php

<h2><center>Device Review Database</center></h2>
		<table width='120%' border='1' cellpadding='1'
		cellspacing='1' align='center'>
               <tr>
		<th align='center'>Device Number</th>
		<th align='center'>Device Revision</th>
		<th align='center'>Device Site</th>
		<th align='center'>Device Platform</th>
		<th align='center'>Device DIB_ID</th>
		<th align='center'>Socket number</th>
		<th align='center'>Socket Type</th>
		<th align='center'>Socket Part Number</th>
		<th align='center'>Subcon Site</th>
		<th align='center'>Subcon name</th>
		<th align='center'>Remarks</th>
	</tr>	  
			
<?php		
while($sqlfetchitem=mysql_fetch_array($sqlitem))
{	
	 $device_num = $row['device_num'];
	 $device_rev = $row['device_rev'];
	 $device_site = $row['device_site'];
	 $device_platform = $row['device_platform'];
	 $device_dibid = $row['device_dibid'];
	 $socketnum = $row['socket_idnum'];
	 $device_socketID = $row['device_socketID'];
	 $device_subconID = $row['device_subconID'];
	 $device_remark = $row['device_remark'];
 
	$query_rev = "SELECT rev_label
				  FROM rev
				  WHERE rev_id = '$device_rev' ";
	$results_rev = mysql_query($query_rev)
		or die (mysql_error());
	$row_rev = mysql_fetch_array ($results_rev);
	//extract ($row_rev);
	$rev_label = $row_rev['rev_label']; 
	
		 
	$query_site = "SELECT site_type
				  FROM site
				  WHERE site_id = '$device_site' ";
	$results_site = mysql_query($query_site)
		or die (mysql_error());
	$row_site = mysql_fetch_array ($results_site);
	//extract ($row_site);
	$site_type = $row_site['site_type'];
	 
	 $query_platform = "SELECT platform_model
						FROM platform
						WHERE platform_id = '$device_platform' ";
	$results_platform = mysql_query($query_platform)
		or die (mysql_error());
	$row_platform = mysql_fetch_array ($results_platform);
	//extract ($row_platform);
	$platform_model = $row_platform['platform_model'];
	
	 
	$query_soc = "SELECT socket_type, socket_partno
				FROM socket
				WHERE socket_id = '$device_socketID' ";
	$results_soc = mysql_query($query_soc)
		or die (mysql_error());
	$row_soc = mysql_fetch_array ($results_soc);
	//extract ($row_soc);
	$sockettype = $row_soc['socket_type'];	
	$socketpartno = $row_soc['socket_partno'];
	 
	
	$query_sub = "SELECT subcon_site, subcon_name
				FROM subcon
				WHERE subcon_id = '$device_subconID' ";
	$results_sub = mysql_query($query_sub)
		or die (mysql_error());
	$row_sub = mysql_fetch_array ($results_sub);
	//extract ($row_sub);
	$subconsite = $row_sub['subcon_site'];
	$subconname = $row_sub['subcon_name'];	
	  
?>	 
	<tr>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_num ;			
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $rev_label ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $site_type ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $platform_model  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_dibid  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketnum  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $sockettype  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketpartno  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $subconsite  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $subconname  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="20%">
		<?php 	
				echo $device_remark  ;		
		?>
		</td>
	
<?php
}
?>
include "header.php"; // my sql connection
extract($_REQUEST);
extract($_POST);
$searchstring=$_REQUEST['searchstring'];
include("pagination.php");
		$q_limit =4;
$errMsg = 0;
if( isset($_GET['start']) ){
	$start = $_GET['start'];
}else{
	$start = 0;
}
$filePath = "example.php"; 
$otherParams="&searchstring=".$_REQUEST['searchstring'];

?>

<html>
<head>
<title>example</title>

</head>

<body>
<h2><center>Device Review Database</center></h2>
		<table width='120%' border='1' cellpadding='1'
		cellspacing='1' align='center'>
               <tr>
		<th align='center'>Device Number</th>
		<th align='center'>Device Revision</th>
		<th align='center'>Device Site</th>
		<th align='center'>Device Platform</th>
		<th align='center'>Device DIB_ID</th>
		<th align='center'>Socket number</th>
		<th align='center'>Socket Type</th>
		<th align='center'>Socket Part Number</th>
		<th align='center'>Subcon Site</th>
		<th align='center'>Subcon name</th>
		<th align='center'>Remarks</th>
	</tr>	  

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
	FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
	$sqlitem=mysql_query("SELECT *
	FROM device
	WHERE device_num LIKE '%$val_d%' or '%$val_d'
	ORDER BY device_id  DESC limit $start,$q_limit");
	$no_rows=mysql_num_rows($user1);
	$row=mysql_num_rows($sqlitem);
	if($row>0)
	{	
	while($sqlfetchitem=mysql_fetch_array($sqlitem))
{	
	 $device_num = $row['device_num'];
	 $device_rev = $row['device_rev'];
	 $device_site = $row['device_site'];
	 $device_platform = $row['device_platform'];
	 $device_dibid = $row['device_dibid'];
	 $socketnum = $row['socket_idnum'];
	 $device_socketID = $row['device_socketID'];
	 $device_subconID = $row['device_subconID'];
	 $device_remark = $row['device_remark'];
 
	$query_rev = "SELECT rev_label
				  FROM rev
				  WHERE rev_id = '$device_rev' ";
	$results_rev = mysql_query($query_rev)
		or die (mysql_error());
	$row_rev = mysql_fetch_array ($results_rev);
	//extract ($row_rev);
	$rev_label = $row_rev['rev_label']; 
	
		 
	$query_site = "SELECT site_type
				  FROM site
				  WHERE site_id = '$device_site' ";
	$results_site = mysql_query($query_site)
		or die (mysql_error());
	$row_site = mysql_fetch_array ($results_site);
	//extract ($row_site);
	$site_type = $row_site['site_type'];
	 
	 $query_platform = "SELECT platform_model
						FROM platform
						WHERE platform_id = '$device_platform' ";
	$results_platform = mysql_query($query_platform)
		or die (mysql_error());
	$row_platform = mysql_fetch_array ($results_platform);
	//extract ($row_platform);
	$platform_model = $row_platform['platform_model'];
	
	 
	$query_soc = "SELECT socket_type, socket_partno
				FROM socket
				WHERE socket_id = '$device_socketID' ";
	$results_soc = mysql_query($query_soc)
		or die (mysql_error());
	$row_soc = mysql_fetch_array ($results_soc);
	//extract ($row_soc);
	$sockettype = $row_soc['socket_type'];	
	$socketpartno = $row_soc['socket_partno'];
	 
	
	$query_sub = "SELECT subcon_site, subcon_name
				FROM subcon
				WHERE subcon_id = '$device_subconID' ";
	$results_sub = mysql_query($query_sub)
		or die (mysql_error());
	$row_sub = mysql_fetch_array ($results_sub);
	//extract ($row_sub);
	$subconsite = $row_sub['subcon_site'];
	$subconname = $row_sub['subcon_name'];	
	  
?>	 
	<tr>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_num ;			
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $rev_label ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $site_type ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $platform_model  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $device_dibid  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketnum  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $sockettype  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $socketpartno  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="5%">
		<?php 	
				echo $subconsite  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="10%">
		<?php 	
				echo $subconname  ;		
		?>
		</td>
		<td bgcolor="#ffffff" width="20%">
		<?php 	
				echo $device_remark  ;		
		?>
		</td>
</tr>
	
<?php
}
?>

	}
	?>	

<?php
   $count++;
   if($count==3)
   {
  echo "&nbsp;<br>";
   $count=0;
   }
  else
  {
 
  echo"<div class='normal_text_light' align='right'><p> NO Items Here.</p></div>";
 
  }
?>	
<span class="normal_text_light">
                <?php
	paginate $start,$q_limit,$no_rows,$filePath,$otherParams); ?>
              </span>
</table>
</body>
</html>

did you try like this?

Hi.. the results are still the same.

Hi.. the results are still the same.

if(isset($_REQUEST['devicesearch']))
{
$devicesearch=$_REQUEST['devicesearch'];
}
else
{
$devicesearch=$_POST['devicesearch'];
}

$filePath = "example.php";// this is your present page name not exmple.php.
$otherParams="&devicesearch=".$devicesearch;

check the code with 'echo' where do you struct. find errors slove them

Hi i had found the error and solved them. But i had faced another new 'challenge' which is a warning sign : Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given on line 52:

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
	FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
	$sqlitem=mysql_query("SELECT *
	FROM device
	WHERE device_num LIKE '%$val_d%' or '%$val_d'
	ORDER BY device_id  DESC limit $devicesearch,$q_limit");
	$no_rows=mysql_num_rows($user1);
	[I][U][B]$rows = mysql_num_rows($sqlitem);[/B][/U][/I]
	echo $rows;
	if($rows>0)
	{	
	?>
<h2><center>Device Review Database</center></h2>
		<table width='120%' border='1' cellpadding='1'
		cellspacing='1' align='center'>
			<tr>
		<th align='center'>Device Number</th>
		<th align='center'>Device Revision</th>
		<th align='center'>Device Site</th>
		<th align='center'>Device Platform</th>
		<th align='center'>Device DIB_ID</th>
		<th align='center'>Socket number</th>
		<th align='center'>Socket Type</th>
		<th align='center'>Socket Part Number</th>
		<th align='center'>Subcon Site</th>
		<th align='center'>Subcon name</th>
		<th align='center'>Remarks</th>
			</tr>	  
			
<?php		

while($row=mysql_fetch_assoc($sqlitem))
{	
	 $device_num = $row['device_num'];
	 $device_rev = $row['device_rev'];
	 $device_site = $row['device_site'];
	 $device_platform = $row['device_platform'];
	 $device_dibid = $row['device_dibid'];
	 $socketnum = $row['socket_idnum'];
	 $device_socketID = $row['device_socketID'];
	 $device_subconID = $row['device_subconID'];
	 $device_remark = $row['device_remark'];

Hi i had found the error and solved them. But i had faced another new 'challenge' which is a warning sign : Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given on line 52:

<?php
    $count=0;
	$val_d = $_POST['devicesearch'];
	$user1=mysql_query("SELECT *
	FROM device WHERE device_num LIKE '%$val_d%' or '%$val_d' ");
	$sqlitem=mysql_query("SELECT *
	FROM device
	WHERE device_num LIKE '%$val_d%' or '%$val_d'
	ORDER BY device_id  DESC limit $devicesearch,$q_limit");
	$no_rows=mysql_num_rows($user1);
	[I][U][B]$rows = mysql_num_rows($sqlitem);[/B][/U][/I]
	echo $rows;
	if($rows>0)
	{	
	?>
<h2><center>Device Review Database</center></h2>
		<table width='120%' border='1' cellpadding='1'
		cellspacing='1' align='center'>
			<tr>
		<th align='center'>Device Number</th>
		<th align='center'>Device Revision</th>
		<th align='center'>Device Site</th>
		<th align='center'>Device Platform</th>
		<th align='center'>Device DIB_ID</th>
		<th align='center'>Socket number</th>
		<th align='center'>Socket Type</th>
		<th align='center'>Socket Part Number</th>
		<th align='center'>Subcon Site</th>
		<th align='center'>Subcon name</th>
		<th align='center'>Remarks</th>
			</tr>	  
			
<?php		

while($row=mysql_fetch_assoc($sqlitem))
{	
	 $device_num = $row['device_num'];
	 $device_rev = $row['device_rev'];
	 $device_site = $row['device_site'];
	 $device_platform = $row['device_platform'];
	 $device_dibid = $row['device_dibid'];
	 $socketnum = $row['socket_idnum'];
	 $device_socketID = $row['device_socketID'];
	 $device_subconID = $row['device_subconID'];
	 $device_remark = $row['device_remark'];
#
$sqlitem=mysql_query("SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'
ORDER BY device_id DESC limit $start,$q_limit");
$no_rows=mysql_num_rows($user1);
$row=mysql_num_rows($sqlitem);

in above query you are placing $devicesearch. use
$start in place of $devicesearch.

#
$sqlitem=mysql_query("SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'
ORDER BY device_id DESC limit $start,$q_limit");
$no_rows=mysql_num_rows($user1);
$row=mysql_num_rows($sqlitem);

in above query you are placing $devicesearch. use
$start in place of $devicesearch.

Great.. thanks..
the table display is out.. however all the results/queries are mixed up. and some of the links i.e. next/previous are not working properly too. Am trying to figure out where the problem is.
Well get back again if i encounter problem again..

Thanks again mate..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.