So I am creating this website promoting products that are organized around two variables and four categories. I am using XHTML, CSS, and PHP. I have 32 products, 8 in 4 categories, that each have a certain price and a certain weight. Is there some way I can assign these size and weight variables to the div tags or some other containing tag using PHP or Javascript, and reorder the products in each category according to their size and weight? It is very hard to do this "by hand" in HTML if I want to have separate pages for the user to be able to order according to price or weight. Thanks
Well what most people will do with projects like this is to make an sql database to hold your product info- say `name_of_product`, `weight`, `price` etc. Then code your page in PHP, check for a variable (something like http://yoursite.com/products.php?order=high_price), then in your php script call to the database like: <? if(!empty($_GET['order'])){ switch($_GET['order']){ case "high_price": $orderBy = "price"; $way = "desc"; break; case "low_price": $orderBy = "price"; $way = "asc"; break; default: } $query = 'select * from `products` order by `' . $orderBy . '` ' . $way . ';'; // Then query and echo result // } ?> PHP: Or at least that's the way I would do it. . . And you would add checks for ordering by weight and such. I suppose you could do it with javascript, which is nice because you don't need to refresh, but it would be tricky. . . I would have to hammer it out but I think a bubble sort loop based on .innerHTML of a certain div within a div would work. . .