Just wondering if any of you can help me out with a small issue I've been having with PHP.
I've got a Database setup on this web site I'm currently working on FundraiserFactory.com. If you check the front page, you will see that under "Fund Raising Products and Ideas" There's a list of keywords that I need alphabetized.
Here's how the Database is Setup with 2 examples:
Code:Products Table: p_id: 10 p_name: Clothing and Apparel p_keywords: T-Shirt, Canvas Bag, Tote Bag, drawstring, Backpack p_folder: clothing_and_apparel p_id: 11 p_name: Food and Beverage p_keywords: Gourmet Food, Cookie, Pizza, Dessert, Cheesecake p_folder: food_and_beverage
The problem is that I need to be able to take all those keywords, break them up, and alphabetize them on my front page at FundraiserFactory.com. Here's what I tried so far:
PHP Code:$query = "SELECT * FROM products ORDER BY p_keywords ASC";
$result = mysql_query($query);
for ($count=0; $count < mysql_numrows($result); $count++) {
$keywords = mysql_result($result, $count, "p_keywords");
$product_link = mysql_result($result, $count, "p_folder");
$keyword_array = explode(', ', $keywords);
sort($keyword_array);
foreach ($keyword_array as $key) {
print "<a href=\"http://fundraiserfactory.com/products/$product_link\">$key</a>, ";
}
}
All this is doing though, is taking each set of keyword arrays and alphabetizing them instead of breaking up the words and making them individuals.
I would like to just have all the keywords in each array, put into one Array instead of multiple arrays. (And then Sort that Array once all the product keywords are listed together.)
This is the first time I've ever had to use the Explode function, so any help is greatly appreciated!



Reply With Quote

Bookmarks