Skip to content

Instantly share code, notes, and snippets.

@mocavada
Last active January 3, 2018 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mocavada/d0169816da0346afc3fe3f93c1c70575 to your computer and use it in GitHub Desktop.
Save mocavada/d0169816da0346afc3fe3f93c1c70575 to your computer and use it in GitHub Desktop.
Online Store
<?php
require( 'includes/config.inc.php' );
$query = "SELECT * FROM Products";
$result = mysqli_query( $db, $query ) or die(mysqli_error($db) . '<br />' . $query );
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Products - <?php echo SITE_TITLE ?></title>
<!-- link to the main stylesheet -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/style.css" />
<!--[if lt IE 9]>
<script src="js/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<h1>
<a href="index.php">
<?php echo SITE_TITLE; ?>
</a>
</h1>
</header>
<main>
<h2>Products</h2>
<ul class="products">
<?php while( $row = mysqli_fetch_assoc( $result ) ): ?>
<li>
<h3 class="product-name">
<?php echo $row['product_name']; ?>
</h3>
<p class="description short"><?php echo substr(($row['description']), 0, 100); ?> ....</p>
<p class="price"><?php echo $row['price']; ?></p>
<img style="max-width: 100px;" class="image" src="<?php echo $row['image_url']; ?>" alt="Product Name" />
</li>
<?php endwhile; ?>
</ul>
</main>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment