ayuda con catalogo en php
Hola, soy un aprendiz de php, y estoy haceindo un catalogo, y me gustaria saber como hago para que cuando un usuario busque un producto le muestre un maximo de 10 por pagina, o sea, si hay 50 productos en el catalogo, que hayan 5 paginas mostrando de a 10 productos, con un link que diga "siguiente", me entienden??? espero que me puedan ayudar....
este es el script del catalogo:
<?php
/* Program: ShowPets.php
* Desc: Displays all the pets in a category. Category
* is passed in a variable from a form. The
* information for each pet is displayed on a
* single line, unless the pet comes in more than
* one color. If the pet comes in colors, a single
* line is displayed without a picture and a line
* for each color, with pictures, is displayed
* following the single line. Small pictures are
* displayed, which are links to larger pictures.
*/
?>
<html>
<head><title>Pet Catalog</title></head>
<body topmargin="0" marginheight="0">
<?php
include("misc.inc");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
/* Select pets of the given type */
$query = "SELECT * FROM Pet
WHERE petType="{$_POST['interest']}""; #27
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<table cellspacing='10' border='0' cellpadding='0'
width='100%'>";
echo "<tr><td colspan='5' align='right'>
Click on any picture to see a larger
version.<br><hr>
</td></tr>n";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) #38
{
$f_price = number_format($row['price'],2);
/* check whether pet comes in colors */
$query = "SELECT * FROM Color
WHERE petName='{$row['petName']}'"; #44
$result2 = mysql_query($query) or die(mysql_error()); #45
$ncolors = mysql_num_rows($result2); #46
/* display row for each pet */
echo "<tr>n";
echo "<td>{$row['petID']}</td>n";
echo "<td><font size='+1'>
<b>{$row['petName']}</b></font></td>n";
echo "<td>{$row['petDescription']}</td>n";
/* display picture if pet does not come in colors */
if ( $ncolors <= 1 ) #55
{
echo "<td><a href='../images/{$row['pix']}'
border='0'>
<img src='../images/{$row['pix']}' border='0'
width='100' height='80'></a></td>n";
}
echo "<td align='center'>$$f_price</td>n
</tr>n";
/* display row for each color if pet comes in colors */
if ($ncolors > 1 ) #65
{
while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC))
{
echo "<tr><td colspan=2> </td>
<td>{$row2['petColor']}</td>
<td><a href='../images/{$row2['pix']}'
border='0'>
<img src='../images/{$row2['pix']}' border='0'
width='100' height='80'></a></td>n";
}
}
echo "<tr><td colspan='5'><hr></td></tr>n";
}
echo "</table>n";
echo "<div align='center'>
<a href='PetCatalog.php'>
<b>See more pets</b></a></div>";
?>
</body></html>
gracias,....
este es el script del catalogo:
<?php
/* Program: ShowPets.php
* Desc: Displays all the pets in a category. Category
* is passed in a variable from a form. The
* information for each pet is displayed on a
* single line, unless the pet comes in more than
* one color. If the pet comes in colors, a single
* line is displayed without a picture and a line
* for each color, with pictures, is displayed
* following the single line. Small pictures are
* displayed, which are links to larger pictures.
*/
?>
<html>
<head><title>Pet Catalog</title></head>
<body topmargin="0" marginheight="0">
<?php
include("misc.inc");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
/* Select pets of the given type */
$query = "SELECT * FROM Pet
WHERE petType="{$_POST['interest']}""; #27
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<table cellspacing='10' border='0' cellpadding='0'
width='100%'>";
echo "<tr><td colspan='5' align='right'>
Click on any picture to see a larger
version.<br><hr>
</td></tr>n";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) #38
{
$f_price = number_format($row['price'],2);
/* check whether pet comes in colors */
$query = "SELECT * FROM Color
WHERE petName='{$row['petName']}'"; #44
$result2 = mysql_query($query) or die(mysql_error()); #45
$ncolors = mysql_num_rows($result2); #46
/* display row for each pet */
echo "<tr>n";
echo "<td>{$row['petID']}</td>n";
echo "<td><font size='+1'>
<b>{$row['petName']}</b></font></td>n";
echo "<td>{$row['petDescription']}</td>n";
/* display picture if pet does not come in colors */
if ( $ncolors <= 1 ) #55
{
echo "<td><a href='../images/{$row['pix']}'
border='0'>
<img src='../images/{$row['pix']}' border='0'
width='100' height='80'></a></td>n";
}
echo "<td align='center'>$$f_price</td>n
</tr>n";
/* display row for each color if pet comes in colors */
if ($ncolors > 1 ) #65
{
while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC))
{
echo "<tr><td colspan=2> </td>
<td>{$row2['petColor']}</td>
<td><a href='../images/{$row2['pix']}'
border='0'>
<img src='../images/{$row2['pix']}' border='0'
width='100' height='80'></a></td>n";
}
}
echo "<tr><td colspan='5'><hr></td></tr>n";
}
echo "</table>n";
echo "<div align='center'>
<a href='PetCatalog.php'>
<b>See more pets</b></a></div>";
?>
</body></html>
gracias,....