Skip to content

Instantly share code, notes, and snippets.

@mocavada mocavada/index.php
Last active Jan 3, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.