karlokokkak

Untitled

Mar 28th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1.   <?php
  2. include_once "../konfiguracija.php";
  3. include 'includes/head.php';
  4. include 'includes/izbornik.php';
  5. //Restore Product
  6. if(isset($_GET['restore'])) {
  7.  $id = sanitize($_GET['restore']);
  8.  $restorirana=$veza->prepare("UPDATE products SET deleted = 0 WHERE id='$id';");
  9.  $restorirana->execute();
  10.  header('Location: products.php');exit;
  11. }
  12. ?>
  13. <?php
  14. $format = new NumberFormatter("en_US",NumberFormatter::CURRENCY);
  15. $p_result =$veza->prepare( "SELECT * FROM `products` WHERE `deleted`=1;");
  16. $p_result ->execute();
  17. ?>
  18. <h2 class="text-center">Products</h2>
  19. <div class="clearfix"></div>
  20. <hr>
  21. <table class="table table-bordered table-condensed talbe-striped">
  22.  <thead>
  23.    <th>Restore</th>
  24.    <th>Product</th>
  25.    <th>Price</th>
  26.    <th>Parent ~ Category</th>
  27.    <th>Featured</th>
  28.    <th>Sold</th>
  29.  </thead>
  30.  <tbody>
  31.     <?php while ($product = $p_result->fetch(PDO::FETCH_ASSOC)):
  32.       $childId = $product['categories'];
  33.        $catSql = $veza->prepare("SELECT * FROM categories WHERE id='$childId';");
  34.        $result= $catSql->execute();
  35.        $child = $catSql->fetch(PDO::FETCH_ASSOC);
  36.        $parentId = $child['parent'];
  37.          $parentSql = $veza->prepare("SELECT * FROM categories WHERE id='$parentId';");
  38.         $parentSql->execute();
  39.          $parent =$parentSql->fetch(PDO::FETCH_ASSOC);
  40.          $category = $parent['category'].'~'.$child['category'];
  41.    ?>
  42.     <tr>
  43.      <td>
  44.       <a href="archived.php?restore=<?php echo $product['id']; ?>" class ="button"><i class="fas fa-undo"></i></a>
  45.     </td>
  46.     <td><?=$product['title'];?></td>
  47.     <td><?php echo $format->format ($product['price']); ?></td>
  48.     <td><?php echo $category;?></td>
  49.     <td><a href="products.php?featured=<?=(($product['featured']== 0)?'1':'0');?>&id=<?=$product['id'];?>"
  50.       class ="button tiny"><i class="fas fa-<?=(($product['featured']==1)?'minus':'plus');?> fa-2x " ></i>
  51.     </a>&nbsp <?=(($product['featured']==1)?'Featured Product': '');?></td>
  52.     <td>0</td>
  53.  </tr>
  54. <?php endwhile; ?>
  55.  </tbody>
  56. </table>
  57. <?php include 'includes/podnozje.php';
  58. include_once 'includes/scripts.php';
  59.  ?>*
Advertisement
Add Comment
Please, Sign In to add comment