Skip to content

Instantly share code, notes, and snippets.

@eakmotion
Created November 23, 2012 07:30
Show Gist options
  • Save eakmotion/4134373 to your computer and use it in GitHub Desktop.
Save eakmotion/4134373 to your computer and use it in GitHub Desktop.
PHP: Product category in single page
<?php include("inc/products.php");
if (isset($_GET["id"])) { // check value if isset $_GET will set to product
$product_id = $_GET["id"];
if (isset($products[$product_id])) {
$product = $products[$product_id];
}
}
if (!isset($product)) { // check value if product !isset will redirect
header("Location: shirts.php");
exit();
}
$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php"); ?>
<div class="section page">
<div class="wrapper">
<div class="breadcrumb"><a href="shirts.php">Shirts</a> &gt; <?php echo $product["name"]; ?></div>
<div class="shirt-picture">
<span>
<img src="<?php echo $product["img"]; ?>" alt="<?php echo $product["name"]; ?>">
</span>
</div>
<div class="shirt-details">
<h1><span class="price">$<?php echo $product["price"]; ?></span> <?php echo $product["name"]; ?></h1>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="<?php echo $product["paypal"]; ?>">
<input type="hidden" name="item_name" value="<?php echo $product["name"]; ?>">
<table>
<tr>
<th>
<input type="hidden" name="on0" value="Size">
<label for="os0">Size</label>
</th>
<td>
<select name="os0" id="os0">
<?php foreach($product["sizes"] as $size) { ?>
<option value="<?php echo $size; ?>"><?php echo $size; ?> </option>
<?php } ?>
</select>
</td>
</tr>
</table>
<input type="submit" value="Add to Cart" name="submit">
</form>
<p class="note-designer">* All shirts are designed by Mike the Frog.</p>
</div>
</div>
</div>
<?php include("inc/footer.php");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment