By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,389 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

Display results from a - z

P: 142

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


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?


$con = mysql_connect("localhost","****","****");
if (!$con)
die('Could not connect: ' . mysql_error());

mysql_select_db("gamehunt_co_za_store", $con);

$result = mysql_query("SELECT * FROM products_description ORDER BY products_name");

while($row = mysql_fetch_array($result))
echo "<a href=\"$row[products_url]\">$row[products_name]</a>";
echo "<br />";
Feb 23 '08 #1
Share this Question
Share on Google+
2 Replies

P: 61
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_letter%".
Feb 23 '08 #2

Expert 5K+
P: 6,050
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...)
$_c = $_GET['letter']; // remember to sanatise this.
SELECT * FROM `table_name` WHERE `catagory` = '{$_c}'";
Hope this helps!
Feb 23 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.