Search the Community
Showing results for tags 'category'.
-
I want to display 10 products from each category from database, I started to display the categories but how to make displaying the products from each one. Here is the code I make so far. I'm not sure am I doing it right with doble sql select , or it can be done only with one. <div class="inner shadow"> <?php $query = 'SELECT id, title_bg AS `title_cat` FROM categories'; $result = $this->db->query($query); ?> <?php foreach ($result->result() as $row): ?> <?php $title_cat = stripslashes($row->title_cat); ?> <div class="prod-sec"> <div class="prod-head"> <h2><?= $title_cat?></h2> <div class="clear"></div> </div> <?php $query1 = 'SELECT t1.id, t1.title_bg AS `Title`, t1.text_bg AS `Text`, t1.price, t1.discount, t1.category_id, t1.promo_page, t2.id AS FileID, t2.ext, FROM products t1 LEFT JOIN products_pictures t2 ON t1.id = t2.object_id LEFT JOIN categories t3 ON t3.id = t1.category_id WHERE t1.promo_page = 0 AND t1.is_active = 1 AND t3.title_bg = '$title_cat' ORDER BY RAND() LIMIT 10'; $result1 = $this->db->query($query1); ?> <div id="classeslist2"> <ul class="home_middle_products"> <?PHP foreach($result1->result() as $row1) { $f = 'files/products_first_page/' . $row1->id . '.jpg'; if(is_file(dirname(__FILE__) . '/../../' . $f)) { $img = site_url() . "files/products_first_page/".$row1->id.".jpg"; } else { $img = site_url() . "files/products/".$row1->id."/".$row1->FileID."_2.".$row1->ext; } $title = stripslashes($row1->Title); $text = character_limiter(strip_tags(stripslashes($row1->Text)),250); $title_url = getLinkTitle($title); $link = site_url()."products/product/".$row1->id."/{$title_url}"; ?> <li style="width: 185px; height: 270px; margin-left: 3px; margin-top: 10px;"> <div class="thumb"> <a href="<?=$link?>"><img src="<?=$img?>" alt="<?=$title?>" width="182" /></a> <div class="price"><?PHP echo product_price($row1, array('show_discount' => false,"show_old_price"=>false, 'show_label' => false, 'view' => 'no')); ?> </div> </div> <h2></h2> <h2><a href="<?=$link?>"><?=$title?></a></h2> <? $text = substr($text, 0, 100); ?> <? if (strlen($text) == 100) $text .= '...' ; ?> <p><?=$text?></p> </li> <?php } ?> <div class="clear"></div> </ul> </div> </div> <?php endforeach; ?> <div class="clear"></div> </div>
-
Hello Community, I have some diffuclties about getting the right logic for article management with subcategories. So everything with Categorys is fine. TABLE: articles articleID title content cat_relatedID TABLE: categories catID cat_name On submit it Works fine where in "selection option" I can select the Category for that post. Now I want to extend it with subcategories. TABLE: articles articleID title content cat_relatedID TABLE: categories catID cat_name TABLE: subcategories subcatID subcat_name related_catID Now the problem is how to relate Cats and Subcats in the form where I am adding new Articles and submit it to mysql. Do I need a additional field in the article table subcatID or anything else? My logic is something to make like in Wordpress when adding New posts you have the option to check categories related with that post. <ul class="list-unstyled categorychecklist "> <li><input type="checkbox" value=""> Category 1 <ul class="children"> <li><input type="checkbox" value=""> Subcategory 1</li> <li><input type="checkbox" value=""> Subcategory 2</li> <li><input type="checkbox" value=""> Subcategory 3</li> </ul> </li> <li><input type="checkbox" value=""> Category 2 <ul class="children"> <li><input type="checkbox" value=""> Subcategory 4</li> <li><input type="checkbox" value=""> Subcategory 5</li> <li><input type="checkbox" value=""> Subcategory 6</li> </ul> </li> <li><input type="checkbox" value=""> Category 3 - No subcategories</li> </ul> LINK should look something like this example: mylink.com/category.php?ID=12&sub_ID=15 Image attached is how it looks now.
-
I am developing a eCommerce website for college semester project,but i am facing a problem with product variant. I want to create different variant and feature depending on products category with filtration. Example: http://www.flipkart.com/mobiles/samsung~brand/pr?sid=tyy,4io&otracker=ch_vn_mobile_filter_Top%20Brands_Samsung Please help me how to create table and fetch the data. Thanks...