A ver si me consigo explicar y me echais un cable please ! Tengo una pagina para busquedas en mi web !!
Esta :

Código PHP:
   <?php
if (!defined('WEB_ROOT')) {
    exit;
}
    // Get the search variable from URL
 
  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable
 
// rows to return
$limit=12; 
 
// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<h3><p align=\"left\" style=\"color:#800000\">Aucun mot a rechercher ...</p><h3>";
  exit;
  }
 
 
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("$dbHost","$dbUser","$dbPass"); //(host, username, password)
 
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("$dbName") or die("Unable to select database"); //select which database we're using
 
// Build SQL Query
// EDIT HERE and specify your table and field names for the SQL query  
$query = "SELECT * FROM tbl_product
INNER JOIN tbl_category
ON tbl_product.cat_id = tbl_category.cat_id
WHERE upper(pd_auteur) LIKE upper(\"%$trimmed%\") OR upper(pd_titre) LIKE upper(\"%$trimmed%\") OR upper(cat_name) LIKE upper(\"%$trimmed%\") OR upper(cat_id2) LIKE upper(\"%$trimmed%\") OR upper(cat_id3) LIKE upper(\"%$trimmed%\") ORDER BY (\"%$trimmed%\") ASC"; 
 
 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
 
if ($numrows == 0)
  {
  echo "<h4><p align=\"left\" style=\"color:#666666\">Aucun resultat sur notre site</p></h4>";
  }
 
// next determine if s has been passed to script, if not use 0
  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
echo "<p align=\"left\" style=\"color:#666666\">Vous avez recherché:   <a style=\"color:#800000\"> "<a style=\"color:#FF9933\">" . $var . "<a style=\"color:#800000\">"</p>";
$s=0;
$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
// begin to show results set
echo "<p align=\"left\" style=\"color:#666666\">Resultat<a style=\"color:#800000\"> $b <a> a <a style=\"color:#800000\">$a <a> de <a style=\"color:#800000\">$numrows</p>";
$count = 1 + $s ;
 
// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
  $auteur = $row["pd_auteur"];
  $titre  = $row["pd_titre"];
  $cat    = $row["cat_name"];
  $prix   = $row["pd_price"];
  $pdId   = $row["pd_id"];
  $catId   = $row["cat_id"];
  $image   =$row ["pd_thumbnail"];
  $etat   =$row ["pd_etat"];
  
  echo "</br><span class=\"notice\"></a># </span>$count"; 
  echo "</br><span class=\"notice\"></a>Titre: </span><a href=index.php?view=detail&c=$catId&p=$pdId />$titre"; 
  echo "<span class=\"notice\"></a> de </span>$auteur";
  echo "</br><span class=\"notice\"></a>Rubrique: </span><a href=\"index.php?c=$catId\">$cat</a> – ";
  echo "</br><span class=\"notice\"></a>Etat: </span>$etat";    
  echo "</br><span class=\"notice\"></a>Prix: </span>$prix €<hr />";
  $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 " <td align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?s=$news&q=$var" . "\"><< 
  [10 Précédentes]</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&q=$var" . "\">[10 Suivantes] >></a>";
  }
 
$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
 
?>    
 ...Hago una busqueda, me da 15 resultados en total, me salen 12 perfecto!, pero quando le doy al paglink para ver los ultimos 3, cambia la pagina me salen los 3 ultimos pero el Count no esta bien ! Me sale de nuevo resultado 1, 2, 3.
Quando tendria que salir resultado 13,14 y 15 ! Y despues tanpoco me sale el paglink para retroceder a los 1s resultados.
Gracias y Salu2
 
 
 

