Display results from a - z

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    Display results from a - z

    Hi,

    How do I display the row results from a-z?

    Example:

    Select a category - a b c d e f g .... And if the user click b, then all the products starting with be is displayed?

    Thanks


    [PHP]
    <?php
    $con = mysql_connect(" localhost","*** *","****");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db ("gamehunt_co_z a_store", $con);

    $result = mysql_query("SE LECT * FROM products_descri ption ORDER BY products_name") ;

    while($row = mysql_fetch_arr ay($result))
    {
    echo "<a href=\"$row[products_url]\">$row[products_name]</a>";
    echo "<br />";
    }mysql_close($c on);
    ?>
    [/PHP]
  • samatair
    New Member
    • Nov 2007
    • 61

    #2
    I think you kept the categories in a separate table and product descriptions in a separate table. if that is the case you could use a join query to select the records and filtering out the category which you selected by using the
    category like "$category_lett er%".

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      use WHERE
      So, if you have your data stored in the table and also a column name which has the catagory theyre in (a, b, c, d...)
      [php]
      $_c = $_GET['letter']; // remember to sanatise this.
      SELECT * FROM `table_name` WHERE `catagory` = '{$_c}'";
      [/php]
      Hope this helps!

      Comment

      Working...