Projecte M07, botiga en php.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

109 lines
3.8 KiB

<?php
include_once('header.php');
include_once('parameters.php');
if (!(isset($_GET['bp_product_id']))) {
header("Location: home.php");
} else {
$product_id = $_GET['bp_product_id'];
}
$sqlPString = "SELECT bp_product_name, bp_product_info, bp_product_price, bp_product_category, bp_product_img_01, bp_product_img_02, bp_product_img_03, bp_product_addDate, bp_user_name";
$sqlPString .= " FROM bp_products INNER JOIN bp_users WHERE bp_product_owner = bp_user_id AND bp_product_id = ?";
$sqlP = $con->prepare($sqlPString);
$sqlP->bind_param("i", $product_id);
$sqlP->execute();
$sqlP->bind_result($product_name, $product_info, $product_price, $product_category, $product_img_01, $product_img_02, $product_img_03, $product_addDate, $product_owner_name);
$sqlP->fetch();
?>
<div class="w3-bar w3-margin"></div>
<div class="w3-bar w3-margin"></div>
<div class="w3-bar w3-margin"></div>
<div class="w3-bar w3-margin"></div>
<!-- Page content -->
<div class="w3-content w3-padding" style="max-width:1564px;margin-top:32px">
<div class="w3-row">
<?php
echo ("
<div class=\"w3-col m5 l4\">
<div class=\"w3-content\" style=\"max-width:800px\">
<img class=\"mySlides\" src=\"img/$product_img_01\" style=\"width:100%\">
<img class=\"mySlides\" src=\"img/$product_img_02\" style=\"width:100%\">
<img class=\"mySlides\" src=\"img/$product_img_03\" style=\"width:100%\">
</div>
<div class=\"w3-center\">
<div class=\"w3-section\">
<button class=\"w3-button w3-light-grey\" onclick=\"plusDivs(-1)\">❮ Prev</button>
<button class=\"w3-button w3-light-grey\" onclick=\"plusDivs(1)\">Next ❯</button>
</div>
<button class=\"w3-button demo\" onclick=\"currentDiv(1)\">1</button>
<button class=\"w3-button demo\" onclick=\"currentDiv(2)\">2</button>
<button class=\"w3-button demo\" onclick=\"currentDiv(3)\">3</button>
</div>
</div>
<div class=\"w3-col m7 l8\" style=\"max-height: 500px;\">
<div class=\"w3-margin-right w3-margin-left\">
<div>
<h2>$product_name</h2>
</div>
<div>
<p>$product_info</p>
</div>
<div>
<h2 style=font-weight:bold>" . number_format($product_price,2,",",".") . " €</h2>
</div>
<div>
<p>Publisher: &nbsp; &nbsp; $product_owner_name</p>
</div>
<div class=\"w3-display-bottomright w3-black w3-padding\">
<div class=\"w3-button\"><a href=\"edit-product.php?product_id=$product_id\" class=\"w3-bar-item w3-button\">Edit</a></div>
<div class=\"w3-button\"><a href=\"delete-product.php?product_id=$product_id\" class=\"w3-bar-item w3-button\">Delete</a></div>
</div>
</div>
</div>
");
?>
</div>
</div>
<!-- End page content -->
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-red", "");
}
x[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " w3-red";
}
</script>
<?php
include('footer.php');
?>