>I want to display data based on the criteria selected by the user eg click
>on size to display smallest to largest, or by price smallest to highest,
>location etc etc
>what is the code I need?

Assuming PHP/MySQL, you'd want something not unlike:

  if (!isset($order)){
    $order = 'title';
    $ascdesc = 'asc';
  $query = "select title, size, price from products ";
  $query .= " order by $order $ascdesc ";
  $products = mysql_query($query, $connection) or error_log(mysql_error());
  echo "<TABLE>\n";
  echo "  <TR>\n";
  echo "    <TH><A HREF=$PHP_SELF?order=title&ascdesc=asc>^</A><A
  echo "    <TH><A HREF=$PHP_SELF?order=size&ascdesc=asc>^</A><A
  echo "    <TH><A HREF=$PHP_SELF?order=price&ascdesc=asc>^</A><A
  echo "  </TR>\n";
  while (list($title, $size, $price) = mysql_fetch_row($products)){
    echo "  <TR><TD>$title</TD><TD>$size</TD><TD>$price</TD></TR>\n";
  echo "</TABLE>\n";

Disclaimer:  I'll be damned if I can ever tell if ^ is suppose to represent
ASC or DESC in these stupid interfaces.  I just click until I get what I
want.  YMMV.

Like Music?  http://l-i-e.com/artists.htm
Off-Topic:  What is the moral equivalent of 'cat' in Windows?

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to