Hi,

I have a page that displays all the products being sold for a site, I would like to add two features to achieve a sorting facility where the user can link on a link at the top of the page (the column heading) which will sort the products by price name manufacter. Secondly I would like the results to be listed with pages at present I have a small amount of product to test the website but it will be holding 100s so like any site at the bottom there is a link for next/2 untill the end any idears??

here is my code:
PHP Code:
<html>
<head>
<title>.:: Kingmonitors ::. All your monitor needs</title>
<link rel=stylesheet href="layout.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php 

include("functions.php");
              
$connec db_connect(); //Calls the connect function

//Select products that match criteria from search page from the database
$query "SELECT * FROM products";

$result mysql_query($query); //Calls the query string in the predified function
        
//If an error occurs display the error information and end the code.
if (!$result)
{
Print(
"Error: ".mysql_error()."<br>"); 
die();
}
?>
<table width="760" height="340" border="0" align="center" cellpadding="0" cellspacing="0" id="main">
  <tr> 
    <td height="125" colspan="2" rowspan="4"> <img src="images/logo.gif" alt="Kingmonitors - All your monitor needs" width="454" height="125" border="0" usemap="#Map"></td>
    <td width="306" colspan="5">&nbsp;</td>
  </tr>
  <tr> 
    <td width="96" height="21"><a href="loginregister.php"><img src="images/my_account.gif" alt="" width="96" height="21" border="0"></a></td>
    <td colspan="3"> <a href="cart.php"> <img src="images/cart.gif" width="137" height="21" border="0" alt=""></a></td>
    <td width="73"> <img src="images/Help.gif" width="73" height="21" alt=""></td>
  </tr>
  <tr> 
    <td width="306" height="65" colspan="5">&nbsp;</td>
  </tr>
  <tr> 
    <td width="101" height="29" colspan="2"> <a href="index.php"><img src="images/home.gif" alt="" width="102" height="29" border="0"></a></td>
    <td width="102"> <a href="search.htm"><img src="images/search.gif" alt="" width="102" height="29" border="0"></a></td>
    <td width="102" colspan="2"><a href="monitors.php"><img src="images/produc_active.gif" alt="" width="102" height="29" border="0"></a></td>
  </tr>
  <tr > 
    <td height="18" colspan="7" background="images/bg_bar.gif"></td>
  </tr>
  <tr valign="top"> 
    <td width="760" colspan="7"> 
      <table width="759" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="10"></td>
        </tr>
      </table>
      
            
      <table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="193" align="center">&nbsp;</td>
          <td width="207" align="center">&nbsp;</td>
        </tr>
      </table>

      <table width="760" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="27"><img src="images/products_bar.gif" width="760" height="27"></td>
        </tr>
        <tr>
          <td align="center" class="searchbox">
<table width="759" border="0" cellspacing="0" cellpadding="0">
              <tr class="head_prod"> 
                <td width="80">&nbsp;</td>
                <td width="245">Name</td>
                <td width="180">Manufacturer</td>
                <td width="80" align="center">Quantity</td>
                <td width="80" align="center">Price</td>
                <td>&nbsp;</td>
                <td width="50">&nbsp;</td>
              </tr>
            </table> 
            <?php
if ($row mysql_fetch_array($result))
{
    while (
$row mysql_fetch_array($result))
    {
?>
            <table width="758" border="0" cellspacing="0" cellpadding="0">
              <tr align="center"> 
          <td colspan="7" class="maintext"></td>
        </tr>
        <tr align="center"> 
                <td class="maintext" width="80"><?php print '<img src="images/small/'.$row["image_name"].'"' ?></td>
                <td width="245" align="left" class="maintext"><?php print $row["name"]; ?></td>
                <td width="180" align="left" class="maintext"><?php print $row["manufacturer"]; ?></td>
                <td width="80" class="maintext">&nbsp;</td>      
                <td width="80" align="right" class="maintext"><?php print "".$row["price"]; ?></td>      
                <td>&nbsp;</td>
                <td width="50" align="center"><a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1"><img src="images/buy.jpg" width="44" height="29" border="0"></a></td>
        </tr>
        <tr align="center"> 
                <td colspan="7" height="4"></td>
        </tr>
      </table>
      <?php

    
//end while
    
//end if
    
else {echo "<br><div align='center'>Sorry, No records were found matching your criteria!</div>";}
?></td>
        </tr>
      </table>
      
    </td>
  </tr>
    <tr> 
    <td width="9" height="2"> <img src="/images/spacer.gif" width="9" height="1" alt=""></td>
    <td width="445" height="2"> <img src="/images/spacer.gif" width="445" height="1" alt=""></td>
    <td width="96" height="2"> <img src="/images/spacer.gif" width="96" height="1" alt=""></td>
    <td width="6" height="2"> <img src="/images/spacer.gif" width="6" height="1" alt=""></td>
    <td width="102" height="2"> <img src="/images/spacer.gif" width="102" height="1" alt=""></td>
    <td width="29" height="2"> <img src="/images/spacer.gif" width="29" height="1" alt=""></td>
    <td width="73" height="2"> <img src="/images/spacer.gif" width="73" height="1" alt=""></td>
  </tr>

</table>
<map name="Map">
  <area shape="poly" coords="106,33" href="#">
  <area shape="poly" coords="92,94,314,96,315,15,102,16,92,7,68,7,44,5,18,3,7,3,8,24,11,45,15,63,19,81,22,96,21,108,21,115,31,120,43,123,60,122,74,121,90,118,98,115,101,108,85,104,74,99,73,95" href="index2.htm">
</map>
</body>
</html>