Php list all category from table-ThrowExceptions

Exception or error:

Table structure -> Table

id   category   year
--------------------    
1    logo      2001
2    web       2002
3    mobile    2003

Is it possible list all category from “flat” table (category – no id) and select only specific category?

Output

   * logo
   * web
   * mobile

/public/products.php?category=

Code

<?php $photo = new Product(); ?>    

  <ul class="category">
  <?php foreach(Product::CATEGORIES as $category) { ?>
     <li class="<?php if($photo->category == $category) { echo 'selected'; } ?>">
         <a href="<?php echo url_for('products.php?category=' . h(u($photo->category))); ?>">
         <?php echo $category; ?>
         </a>
     </li>
  <?php } // ?>
  </ul>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *