Hi,
I have this code that search an specify word in the database. This search is working. 
The only problem that I have is that I wanna show only 7 rows per page. When I wanna 
jump to the next page with results it shows all records in the database(7 rows per 
page).
How can i do to show only the records that match with the search word?



$rows_per_page = 7;
$sql = "SELECT * FROM products";
$rezultat = mysql_query($sql);
$total_records = mysql_num_rows($rezultat);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($rezultat);
mysql_close($conectare);


if (!isset($pagina))
  $pagina = 0;
$start = $pagina * $rows_per_page;
$sql="SELECT id_products, name_product FROM products WHERE name_product LIKE 
'%".$word."%' LIMIT $start, $rows_per_page ";

$result=mysql_query($sql);
if (mysql_num_rows($result) == 0)
{
print '<i>Product not found</i>';
}
while ($row=mysql_fetch_array($result))
{
some code here
}



if ($pagina > 0) {
  $url = "product.php?pagina=" . ($pagina - 1);
  echo "<a href=\"$url\">Previous</a>\n";
}

for ($i = 1; $i < $pages; $i++) {
  $url = "product.php?pagina=" . $i;
  echo "   <a href=\"$url\">$i</a>   ";
}
if ($pagina < ($pages-1)) {
  $url = "product.php?pagina=" . ($pagina + 1);
  echo "<a href=\"$url\">Next</a>\n";
}

Reply via email to