While I am submitting this form via ajax it gets only the fist item. I am new so from the last three day I am looking on the web for a solution bit field. please someone help me.
<?php
include 'db.php';
$result = $mysqli -> query("SELECT * FROM AlmeenaShop LIMIT 8 ");
if($result -> num_rows <1){
/*echo"<h2 >No Record Found</h2>";*/
}else{
?>
<!DOCTYPE html>
<html>
<head>
<title>Insert data in MySQL database using Ajax</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div style="margin: auto;width: 60%;">
<div class="alert alert-success alert-dismissible" id="success" style="display:none;">
×
</div>
<?php foreach ($result as $row ) { ?>
<form id="fupForm" name="form1" method="post">
<div class="single-products">
<div class="productinfo text-center"><img width="200" height="250" alt="" src="<?php echo $row['ImageLocation'] ; ?> " />
<?php if ($row['OfferPrice']>0): ?>
<h2><?php echo "৳ ". $row['OfferPrice'] ." /-"; ?><del class="text-primary"><?php echo "৳ ". $row['SalesPrice'] ." /-"; ?></del></h2>
<?php else : ?>
<h2><?php echo "৳ ". $row['SalesPrice'] ." /-"; ?></h2>
<?php endif ?>
<p><?php echo $row['ProductName'] ; ?></p>
<p><input type="number" name="ProductQuantity" value="1" id="ProductQuantity<?php echo $row['StoreID'] ; ?>" step="1"></p>
<p><input type="hidden" id="StoreID<?php echo $row['StoreID'] ; ?>" name="StoreID" value="<?php echo $row['StoreID'] ; ?>"></p>
</div>
</div>
<input type="button" name="target" class="btn btn-primary" value="Save to database" id="<?php echo $row['StoreID'] ; ?>">
</form>
</div>
<?php
} /* FOr Whole Loop*/
}/* for if then else loop*/
?>
<script>
$(document).ready(function() {
$('.btn').on('click', function() {
var target = $(".btn").attr("id");
$("#"+target).attr("disabled", "disabled");
var StoreID = $('#StoreID'+target).val();
var ProductQuantity = $('#ProductQuantity'+target).val();
if(StoreID!="" && ProductQuantity!=""){
$.ajax({
url: "MyCart.php",
type: "POST",
data: {
StoreID: StoreID,
ProductQuantity: ProductQuantity
},
cache: false,
success: function(){
alert("ok");
}
});
}
else{
alert('Please fill all the field !StoreID: StoreID , ProductQuantity: ProductQuantity');
}
});
});
</script>
</body>
</html>
<script>
$(document).ready(function() {
var buttons = document.getElementsByTagName("button");
var buttonsCount = buttons.length;
for (var i = 0; i <= buttonsCount; i += 1) {
buttons[i].onclick = function(e) {
//alert(this.id);
var targetid= this.id;
var PImg = $('#PImg_'+targetid).val();
var PName = $('#PName_'+targetid).val();
var PRPrice = $('#PRPrice_'+targetid).val();
var POPrice = $('#POPrice_'+targetid).val();
var PQ = $('#PQ_'+targetid).val();
var PSID = $('#PSID_'+targetid).val();
//alert(this.id+"StoreID"+StoreID+"ProductQuantity"+ProductQuantity);
if(PSID!="" && PQ!=""){
$.ajax({
url: "MyCart.php",
type: "POST",
data: {
PImg: PImg,
PName: PName,
PRPrice: PRPrice,
POPrice: POPrice,
PQ: PQ,
PSID: PSID
},
cache: false,
success: function(){
//alert("ok");
window.location.reload();
}
});
}
else{
// alert('Please fill all the field !');
}
}
};
});
</script>
<script>
$(document).ready(function() {
var buttons = document.getElementsByTagName("button");
var buttonsCount = buttons.length;
for (var i = 0; i <= buttonsCount; i += 1) {
buttons[i].onclick = function(e) {
//alert(this.id);
var targetid= this.id;
var PImg = $('#PImg_'+targetid).val();
var PName = $('#PName_'+targetid).val();
var PRPrice = $('#PRPrice_'+targetid).val();
var POPrice = $('#POPrice_'+targetid).val();
var PQ = $('#PQ_'+targetid).val();
var PSID = $('#PSID_'+targetid).val();
//alert(this.id+"StoreID"+StoreID+"ProductQuantity"+ProductQuantity);
if(PSID!="" && PQ!=""){
$.ajax({
url: "MyCart.php",
type: "POST",
data: {
PImg: PImg,
PName: PName,
PRPrice: PRPrice,
POPrice: POPrice,
PQ: PQ,
PSID: PSID
},
cache: false,
success: function(){
//alert("ok");
window.location.reload();
}
});
}
else{
// alert('Please fill all the field !');
}
}
};
});
</script>
<?php
session_start();
include 'db.php';
//Get the current page number
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
//The formula for php pagination
$no_of_records_per_page = 21;
$offset = ($pageno-1) * $no_of_records_per_page;
//Get the number of total number of pages
$result = $mysqli -> query("SELECT * FROM AlmeenaShop ");
$total_rows=$result -> num_rows;
$total_pages = ceil($total_rows / $no_of_records_per_page);
//Constructing the SQL Query for pagination
$ConstructingPagination= $mysqli -> query("SELECT * FROM AlmeenaShop ORDER BY StoreID DESC LIMIT $offset, $no_of_records_per_page");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Almeena Shop</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/shop-homepage.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<!-----------Nav Bat---------------->
<div class="container">
<!-- Navigation Start -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark text-white">
<H1><span style="color:yellow">Almeena</span> <span style="color:white">Shop</span></H1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.php">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
<li class="nav-item">
<a style="color:gold" class="nav-link" href="MyCart.php"><i style="color:gold" class="fa fa-shopping-cart"></i> <?php echo $ItemCount=count($_SESSION['cart']); ?></a>
</li>
</ul>
</div>
</nav>
</div>
<!-- Navigation Start -->
<div class="container bg-light p-5">
<!-------####### Carosel Start ###########-------------------->
<div id="carouselExampleControls" class="carousel slide " data-ride="carousel">
<div class="carousel-inner ">
<div class="carousel-item active">
<img src="StoreImg/grocery_3.jpg" height="300"class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="StoreImg/Shopping-basket.jpg" height="300" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="StoreImg/3c.jpg" height="300" class="d-block w-100" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-------####### Carosel END ###########-------------------->
</div>
<!-- Page Content -->
<div class="container">
<div class="row">
<!--------------------------LEft Cploum For Category Start ---------------------------------------->
<div class="col-lg-3 mt-5">
<?php
$ProductCategoryResult = $mysqli -> query ("SELECT ProductCategory, count(ProductCategory)AS PCC FROM AlmeenaShop GROUP BY ProductCategory ORDER BY ProductCategory");
?>
<div class="card border-primary mb-3" style="max-width: 18rem;">
<div class="card-header"><h5>Our Products</h5></div>
<div class="card-body text-primary">
<?php foreach ($ProductCategoryResult as $PCrow){
?>
<div class=" card-title" data-toggle="collapse" data-target="#<?php echo $PCrow['ProductCategory']; ?>" ><?php echo $PCrow['ProductCategory']; ?>
<div class="list-group collapse" id="<?php echo $PCrow['ProductCategory']; ?>" >
<ul>
<?php
$ProductSubCategoryResult = $mysqli -> query("SELECT ProductSubCategory FROM AlmeenaShop WHERE ProductCategory='".$PCrow['ProductCategory']."' GROUP BY ProductSubCategory ORDER BY ProductSubCategory ");
foreach ($ProductSubCategoryResult as $PSCrow){
?>
<li><?php echo $PSCrow['ProductSubCategory'];?> </li>
<?php } ?>
</ul>
</div>
</div>
<?php } ?>
<div class=" card-title" data-toggle="collapse" data-target="#demo241">Offer
<div class="list-group collapse" id="demo241" >
<ul>
<li>--------- </li>
<li>--------- </li>
<li>--------- </li>
<li>--------- </li>
<li>--------- </li>
<li>--------- </li>
</ul>
</div></div>
</div>
</div>
</div>
<!-- /.col-lg-3 -->
<!--------------------------LEft Cploum For Category End ---------------------------------------->
<!-----#########################Rignt Cploum For Product Start ############################------>
<div class="col-lg-9 mt-5">
<ul class="pagination">
<li class="page-item" ><a class="page-link" href="?pageno=1">First</a></li>
<li class="page-item <?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
</li>
<li class=" page-item <?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
</li>
<li class="page-item"><a class="page-link" href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
<p>Page <?php echo $total_pages; ?> of <?php echo $pageno; ?></p>
<div class="row">
<?php foreach ($ConstructingPagination as $row) { ?>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100" >
<img class="card-img-top p-2" src="http://almeenashop.com/<?php echo $row['ImageLocation'] ; ?>" alt="">
<div class="card-body">
<h4 class="card-title">
<p style="color:black" ><?php echo $row['ProductName'] ; ?></p>
<a class="text-success" href="#">
<p style="color:orange">Price :</p>
<?php if ($row['OfferPrice']>0): ?>
<?php echo "৳ ". $row['OfferPrice'] ." /-"; ?><br /><del class="text-primary"><?php echo "৳ ". $row['SalesPrice'] ." /-"; ?></del>
<?php else : ?>
<?php echo "৳ ". $row['SalesPrice'] ." /-"; ?>
<?php endif ?>
</a>
</h4>
</div>
<div class="card-footer">
<form id="CartForm" name="form1" method="post" enctype="multipart/form-data">
<input type="hidden" name="PImg" id="PImg_<?php echo $row['StoreID'] ; ?>" value="<?php echo $row['ImageLocation'] ; ?>">
<input type="hidden" name="PName" id="PName_<?php echo $row['StoreID'] ; ?>" value="<?php echo $row['ProductName'] ; ?>">
<input type="hidden" name="PRPrice" id="PRPrice_<?php echo $row['StoreID'] ; ?>" value="<?php echo $row['SalesPrice'] ; ?>">
<input type="hidden" name="POPrice" id="POPrice_<?php echo $row['StoreID'] ; ?>" value="<?php echo $row['OfferPrice'] ; ?>">
<input type="hidden" name="PQ" id="PQ_<?php echo $row['StoreID'] ; ?>" value="1">
<input type="hidden" name="PSID" id="PSID_<?php echo $row['StoreID'] ; ?>" value="<?php echo $row['StoreID'] ; ?>">
<button type="button" class="btn btn-primary" id="<?php echo $row['StoreID'] ; ?>">Add to Cart</button>
</form>
| Details
</div>
</div>
</div>
<?php } ?>
</div>
<!-- /.row -->
</div>
<!-- /.col-lg-9 -->
<!-----######################----Rignt Cploum For Product End -----##########################---------------->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<!------- &&&&&&&& Footer Start &&&&&&&&&&&&&&------------>
<footer id="footer">
<div class="footer-widget bg-dark text-white">
<div class="container pt-4 pb-5">
<div class="row">
<div class="col-sm-2">
<div class="single-widget">
<h5>Service</h5>
<ul>
<li>Online Help</li>
<li>Contact Us</li>
<li>Order Status</li>
<li>Change Location</li>
<li>FAQ’s</li>
</ul>
</div>
</div>
<div class="col-sm-2">
<div class="single-widget">
<h5>Quock Shop</h5>
<ul>
<li>T-Shirt</li>
<li>Mens</li>
<li>Womens</li>
<li>Gift Cards</li>
<li>Shoes</li>
</ul>
</div>
</div>
<div class="col-sm-2">
<div class="single-widget">
<h5>Policies</h5>
<ul>
<li>Terms of Use</li>
<li>Privecy Policy</li>
<li>Refund Policy</li>
<li>Billing System</li>
<li>Ticket System</li>
</ul>
</div>
</div>
<div class="col-sm-2">
<div class="single-widget">
<h5>About Shopper</h5>
<ul>
<li>Company Information</li>
<li>Careers</li>
<li>Store Location</li>
<li>Affillate Program</li>
<li>Copyright</li>
</ul>
</div>
</div>
<div class="col-sm-3 col-sm-offset-1">
<div class="single-widget">
<h5>News</h5>
<form action="#" class="searchform"><input placeholder="Your email address" type="text" /><button class="btn btn-default" type="submit"></button>
<p>Get the most recent updates from<br />
our site and be updated your self...</p>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="footer-bottom">
<div class="container">
<div class="row">
<p class="pull-left">Copyright © 2020 Inc. All rights reserved.</p>
</div>
</div>
</div>
</footer>
<!------- &&&&&&&& Footer End &&&&&&&&&&&&&&------------>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script>
$(document).ready(function() {
var buttons = document.getElementsByTagName("button");
var buttonsCount = buttons.length;
for (var i = 0; i <= buttonsCount; i += 1) {
buttons[i].onclick = function(e) {
//alert(this.id);
var targetid= this.id;
var PImg = $('#PImg_'+targetid).val();
var PName = $('#PName_'+targetid).val();
var PRPrice = $('#PRPrice_'+targetid).val();
var POPrice = $('#POPrice_'+targetid).val();
var PQ = $('#PQ_'+targetid).val();
var PSID = $('#PSID_'+targetid).val();
//alert(this.id+"StoreID"+StoreID+"ProductQuantity"+ProductQuantity);
if(PSID!="" && PQ!=""){
$.ajax({
url: "MyCart.php",
type: "POST",
data: {
PImg: PImg,
PName: PName,
PRPrice: PRPrice,
POPrice: POPrice,
PQ: PQ,
PSID: PSID
},
cache: false,
success: function(){
//alert("ok");
window.location.reload();
}
});
}
else{
// alert('Please fill all the field !');
}
}
};
});
</script>
</body>
</html>
Related
I dont have an idea. What is the problem. The whole website is made/written in php/JS/html/css/mysql.
There is a few pages with menu. It is responsive website. And works fine
There is a gallery. In menu bar you have few options. Example latest, popular, gallery, etc...
The problem is when you click on "Popular" from android device it opens without problem. But when you click on "Popular" from desktop PC/laptop it opens just gallery.
Just that one page is problem everything else works fine. On mobile, tablet and desktop devices. But just that page is problem.
Please if somebody had a similar problem like that or have an Idea how to solve it.
Regards.
Thanks.
<?php
include "web-config.php";
if(isset($_GET['p'])){
if(gettype($_GET['p']) != "array"){
$page = (int)$_GET['p'];
}else{
$page = 0;
}
}else{
header("location: {$webConfig['webhome']}/popular?p=1");
$page = 0;
exit();
}
if($page > 0){
$finalPage = $page - 1;
$realPage = $page;
}else{
$finalPage = 0;
$realPage = $page;
}
?>
<!DOCTYPE html>
<html lang="en">
<?= webHead($webConfig,"Popular{$realPage}") ?>
</head>
<body>
<div class="header">
Popular
</div>
<div class="main" id="main">
<?= webHeaderNav($webConfig) ?>
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://e-hentai.org/popular/?page=".); ($realPage + 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36");
$exec = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode == 200 && preg_match("/<div class=\"glthumb\"/",$exec)){
?>
<div class="main-content">
<section class="main-tabs">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div style="text-align:center;">
<script data-cfasync="false" type="text/javascript" src="//brightadnetwork.com/a/display.php?r=5991602"></script>
<!-- JuicyAds v3.0 -->
<script type="text/javascript" data-cfasync="false" async src="https://poweredby.jads.co/js/jads.js"></script>
<ins id="984072" data-width="728" data-height="102"></ins>
<script type="text/javascript" data-cfasync="false" async>(adsbyjuicy = window.adsbyjuicy || []).push({'adzone':984072});</script>
<!--JuicyAds END-->
</div>
<h2 class="block-title">Popular Gallery</h2>
<div class="tab-content" id="pills-tabContent">
<div id="pills-additions" class="tab-pane animated fadeInRight show active">
<div class="row">
<?php
$getLatest = explode("<div class=\"glthumb\"",$exec);
for($i = 1; $i <= count ($getLatest)-1; $i++){
if(preg_match("/data-src=\"/",$getLatest[$i])){
preg_match("/data-src=\"(.*?)\"/",$getLatest[$i],$getTb);
}else{
preg_match("/src=\"(.*?)\"/",$getLatest[$i],$getTb);
}
preg_match("/\" title=\"(.*?)\"/",$getLatest[$i],$getTtl);
preg_match("/<a href=\"(.*?)\"/",$getLatest[$i],$getLnk);
preg_match("/<a href=\"https:\/\/e-hentai.org\/g\/(.*?)\"/",$getLatest[$i],$getLnk);
preg_match("/id=\"postedpop_(.*?)div><\/div><div>/",$getLatest[$i],$getDesc);
preg_match("/>(.*?)<\//",$getDesc[1],$getDescFinal);
if(!preg_match("/\.php/",$getLnk[1])){
?>
<div class="col-6 col-sm-6 col-md-4 col-lg-4 col-xl-2">
<div class="video-block">
<div class="video-thumb position-relative thumb-overlay" style="tetx-align:center;">
<img alt="" class="img-fluid" src="<?= $getTb[1] ?>" style="height:167px !important;width:auto;margin:auto;display:block;">
</div>
<div class="video-content">
<h2 class="video-title"><?= $getTtl[1] ?></h2>
<div class="video-info d-flex align-items-center">
<span class="video-year"><?= $getDescFinal[1] ?></span>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<?php
if($realPage == 1){
?>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". $realPage ?>" tabindex="0">
<b><?= $realPage ?></b>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 2) ?>" tabindex="0">
<?= $realPage+2 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 1) ?>" tabindex="0">
<?= $realPage+1 ?>
</a>
<?php
}elseif($realPage == 2){
?>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage - 2) ?>" tabindex="0">
<?= $realPage-2 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". $realPage ?>" tabindex="0">
<b><?= $realPage ?></b>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 1) ?>" tabindex="0">
<?= $realPage+1 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 2) ?>" tabindex="0">
<?= $realPage+2 ?>
</a>
<?php
}else{
?>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage - 1) ?>" tabindex="0">
<?= $realPage-1 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage - 2) ?>" tabindex="0">
<?= $realPage-2 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". $realPage ?>" tabindex="0">
<b><?= $realPage ?></b>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 2)?>" tabindex="0">
<?= $realPage+2 ?>
</a>
<a class="btn hvr-sweep-to-right" href="<?= $webConfig['webhome']."/gallery?p=". ($realPage + 1) ?>" tabindex="0">
<?= $realPage+1 ?>
</a>
<?php
}
?>
</div>
</div>
<div style="text-align:center;margin-bottom:10px;">
<script data-cfasync="false" type="text/javascript" src="//brightadnetwork.com/a/display.php?r=5991602"></script>
<!-- JuicyAds v3.0 -->
<script type="text/javascript" data-cfasync="false" async src="https://poweredby.jads.co/js/jads.js"></script>
<ins id="984072" data-width="728" data-height="102"></ins>
<script type="text/javascript" data-cfasync="false" async>(adsbyjuicy = window.adsbyjuicy || []).push({'adzone':984072});</script>
<!--JuicyAds END-->
</div>
</div>
</div>
</div>
</section>
</div>
<?php
}else{
?>
<div class="col-xl-3 col-lg-4 col-md-6">
<h1>Server Busy!</h1>
<h6>Please reload the page or Contact the Administrator.</h6>
</div>
<?php
}
?>
<?= webMainFooter($webConfig) ?>
<?= webFooterBottom($webConfig) ?>
</div>
<?= webFooterJS($webConfig) ?>
</body>
</html>
im trying to send the id of the product selected in portfolio.php page to the page portfolio-detail.php and display the information from database according to the selected id
this is portfolio.php page
<ul class="portfolio-area da-thumbs">
<?php foreach ($product as $value): ?>
<li class="portfolio-item" data-id="id-0" data-type="web">
<div class="span3">
<div class="thumbnail">
<div class="image-wrapp">
<img src="<?php echo $target_dir.'/'.$value['product_pic']; ?>" alt="Portfolio name" title="" />
<article class="da-animate da-slideFromRight">
<a class="zoom" data-pretty="prettyPhoto" href="<?php echo $target_dir.'/'.$value['product_pic']; ?>">
<i class="icon-zoom-in icon-rounded icon-48 active"></i>
</a>
<a href="portfolio-detail.php" data-id="<?=$value['id']; ?>">
<i class="icon-link icon-rounded icon-48 active"></i>
</a>
<div class="hidden-tablet">
<p>
<?php echo $value['product_name']; ?>
</p>
</div>
</article>
</div>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
and this is portfolio-detail.php page
<section id="<?php echo $product['id']; ?>">
<div class="container">
<div class="row">
<div class="span12">
<article>
<div class="heading">
<h4><?php echo $product['product_name']; ?></h4>
</div>
<div class="clearfix">
</div>
<div class="row">
<div class="span8">
<!-- start flexslider -->
<div class="flexslider">
<ul class="slides">
<li>
<img src="<?php echo $target_dir.'/'.$product['product_pic']; ?>" alt="" />
</li>
</ul>
</div>
<!-- end flexslider -->
<p>
<?php echo $product['product_desc']; ?>
</p>
</div>
<div class="span4">
<aside>
<div class="widget">
<div class="project-widget">
<h4 class="rheading">Portfolio detail<span></span></h4>
<ul class="project-detail">
<li><label>Project name :</label> <?php echo $product['product_name']; ?></li>
<li><label>Category :</label> <?php echo $product['product_code']; ?></li>
<li><label>Project date :</label> 12 Apr 2013</li>
<li><label>Project link :</label>www.somelink.com</li>
</ul>
</div>
</div>
</aside>
</div>
</div>
</article>
<!-- end article full post -->
</div>
</div>
</div>
</section>
how to show the details of a product according to the one selected ?
Here's a solution:
In portfolio.php
Change:
<a href="portfolio-detail.php" data-id="<?=$value['id']; ?>">
To:
<a href="portfolio-detail.php?data-id=<?php echo $value['id']; ?>">
Top of portfolio-detail.php add:
$id = $_GET['data-id'];
Do your DB query with $id
$product = {db stuff here};
Of course all proper validation will need to get added.
Im trying the following:
I have a form where some columns are created dynamically depending on the length of a certain array as follows:
<div class="row box-table">
<div class="col-sm-12">
<div class="panel-heading bold panel-title">
<!-- Referral Code -->
<div class="col-xs-<?= $widthReferralCodeColumn ?> text-center">
<span><?= Yii::t('app', 'Referral Code') ?></span>
</div>
<!-- Referral Code -->
<!-- Pay Methods -->
<?php foreach ($hbwellMarginsDataFillers[0]['payMethods'] as $key => $value): ?>
<div class="col-xs-<?= $payMethodsColumnsWidth ?> <?= $style ?> text-center">
<span><?= $key ?></span>
</div>
<?php endforeach ?>
<!-- Pay Methods -->
<!-- Actions -->
<div class="col-xs-<?= $widthActionsColumn ?> text-center">
<span><?= Yii::t('app', 'Actions') ?></span>
</div>
<!-- Actions -->
</div>
<!--<div data-key="%{id}" class="hidden row-model">-->
<div data-key="%{id}" class="row-model">
<div class="table row-type edit-model">
<!--<form id="%{id}" method="post">-->
<form id="formulario" method="post">
<?php foreach ($hbwellMarginsDataFillers as $hbwellMarginsDataFiller): ?>
<div class="row">
<!-- Referral Code -->
<div class="col-xs-<?= $widthReferralCodeColumn ?> <?= $style ?> text-center">
<span data-editable="false" class="toShow" style="display: block" data-id="HbwellMargins[referralCode]" data-original="%{referralCode}"><?= $hbwellMarginsDataFiller['referralCode'] ?></span>
<span data-editable="true" class="toHide" style="display: none">
<div class="form-group hbwell-margins-referralCode"><input type="text" id="hbwell-margins-referralCode" name="HbwellMargins[referralCode]" value="<?= $hbwellMarginsDataFiller['referralCode'] ?>" class="form-control"></div>
</span>
<!-- ORIGINAL -->
<?/*= $hbwellMarginsDataFiller['referralCode'] */?>
<!-- ORIGINAL -->
</div>
<!-- Referral Code -->
<!-- Pay Methods -->
<?php foreach ($hbwellMarginsDataFiller['payMethods'] as $key => $value): ?>
<div class="col-xs-<?= $payMethodsColumnsWidth ?> <?= $style ?> text-center">
<?php if($value === null): ?>
<span data-editable="false" class="toShow" style="display: block" data-id="HbwellMargins[payMethods]" data-original="%{payMethods}">null</span>
<span data-editable="true" class="toHide" style="display: none">
<div class="form-group hbwell-margins-payMethods">
<input type="text" id="hbwell-margins-payMethods" name="HbwellMargins[payMethods]" value="" class="form-control">
</div>
</span>
<!-- ORIGINAL -->
<!--<span>null</span>-->
<!-- ORIGINAL -->
<?php else: ?>
<span data-editable="false" class="toShow" style="display: block" data-id="HbwellMargins[payMethods]" data-original="%{payMethods}"><?= $value ?></span>
<span data-editable="true" class="toHide" style="display: none">
<div class="form-group hbwell-margins-payMethods">
<input type="text" id="hbwell-margins-payMethods" name="HbwellMargins[payMethods]" value="<?= $value ?>" class="form-control">
</div>
</span>
<!-- ORIGINAL -->
<!--<span><?/*= $value */?></span>-->
<!-- ORIGINAL -->
<?php endif ?>
</div>
<?php endforeach ?>
<!-- Pay Methods -->
<!-- Actions -->
<!--<div class="col-xs-<?/*= $widthActionsColumn */?> text-center">
<a id="clickOnEdit" data-editable="false" class="toShow" style="display: block" href="javascript:void(0)" data-id="%{id}" class="edit_button"><span class="glyphicon glyphicon-pencil v-aling-middle icon edit"></span></a>
<button data-editable="true" class="toHide" style="display: none" data-request-id="10" role="button" class="btn btn-sm btn-request accept"><span class="glyphicon glyphicon-ok"></span></button>
<a id="stopOnEdit" data-editable="true" class="toHide" style="display: none" data-request-id="10" role="button" class="hidden btn btn-sm btn-request cancel"><span class="glyphicon glyphicon-remove"></span></a>
</div>-->
<div class="col-xs-<?= $widthActionsColumn ?> text-center">
<a id="clickOnEdit" data-editable="false" class="toShow" style="display: block" href="javascript:void(0)" data-id="%{id}" class="edit_button">
<span class="glyphicon glyphicon-pencil v-aling-middle icon edit"></span>
</a>
<!--<button data-editable = "true" class="toHide" style="display: none" data-request-id="10" role="button" class="btn btn-sm btn-request accept" type="submit" onclick="return epaCuliao();">
<span class="glyphicon glyphicon-ok"></span>
</button>-->
<a id="submitChanges" type="submit" onclick="return epaCuliao();" data-editable="true" class="toHide" style="display: none" data-request-id="10" role="button" class="hidden btn btn-sm btn-request accept">
<span class="glyphicon glyphicon-ok"></span>
</a>
<!--<button id="stopOnEdit" data-editable="true" class="toHide" style="display: none" data-request-id="10" role="button" class=" btn btn-sm btn-request cancel">
<span class="glyphicon glyphicon-remove"></span>
</button>-->
<a id="stopOnEdit" data-editable="true" class="toHide" style="display: none" data-request-id="10" role="button" class="hidden btn btn-sm btn-request cancel"><span class="glyphicon glyphicon-remove"></span></a>
</div>
<!-- Actions -->
</div>
<?php endforeach ?>
</form>
</div>
</div>
</div>
</div>
When pencil icon is clicked form can be edited.
Well my problem is how to get all the information from that form and pass it to a function (actionEditHbwellMargins) in a controller (ClinicController).
I started using JS/JQuery copying code from other parts of my project, but I dont know how to get a solution in this case:
$(document).ready(function () {
var editable_fields = {
'referralCode': 'HbwellMargins[referralCode]',
'payMethods': 'HbwellMargins[payMethods]',
};
document.getElementById('submitChanges').onclick = function() {
edit();
}
function edit() {
alert("Epa culiao");
var el = $(this);
var container = el.closest('.row-type.edit');
var form = container.find("form");
var id = form.attr('id');
var values = {};
var params = 'id='+encodeURI(id);
$.each(editable_fields, function(key,key2){
var input = container.find("[name=\""+key2+"\"]");
var val = input.val();
values[key2] = val;
//para generar la url
params += "&"+key+"="+encodeURI(val);
});
var thisapp = this;
axios.post('/clinic/edit-hbwell-margins?'+params)
.then(function (response) {
$.each(values,function(key,val){
container.find("span[data-id=\""+key+"\"]")
.text(val)
.attr('data-original', val);
container.find("[name=\""+key+"\"]").val(val);
});
container.removeClass('editable');
})
.catch(function (error) {
console.log(error);
edit_cancel();
});
}
}
'payMethods': 'HbwellMargins[payMethods]' will be an array with variable length.
Please would you be so kind to help me or giving me some hint to achieve a solution? I'm desperate to find out a solution.
Thank you!
This is my product page
I want to use checkbox for my product page by jquery.. So that customer can easily find their required product with this checkbox . Please do help me as i am in very early stage of jquery.
Thanks in advance
<!DOCTYPE HTML>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 " lang="sv"><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" lang="sv"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9 ie8" lang="sv"><![endif]-->
<!--[if gt IE 8]> <html class="no-js ie9" lang="sv"><![endif]-->
<html lang="sv">
<script src="assets/js/jquery-1.11.0.min.js"></script>
<body id="rims" class="category category-14 category-falgar hide-right-column lang_sv">
<div id="page">
<div class="columns-container">
<div id="columns" class="container">
<!-- Breadcrumb -->
<div class="breadcrumb clearfix">
<a class="home" href="index.php" title="Återgå till Startsidan"><i class="icon-home"></i></a>
<span class="navigation-pipe" >></span>
<span class="navigation_page">Fälgar</span>
</div>
<!-- /Breadcrumb -->
<div id="slider_row" class="row">
<div id="top_column" class="center_column col-xs-12 col-sm-12"></div>
</div>
<div class="row">
<div id="left_column" class="column col-xs-12 col-sm-3">
<!-- Block layered navigation module -->
<div id="layered_block_left" class="block">
<p class="title_block">Sök Fälgar</p>
<div class="block_content
<form action="#" id="layered_form">
<div>
<div class="layered_filter">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">Storlek</span>
</div>
<ul id="" class="col-lg-12 ">
<?php include 'php/config.php';
$sql =mysql_query("select * from size");
while($row=mysql_fetch_array($sql)){
?>
<li class="nomargin hiddable col-lg-6">
<input type="radio" class="radio" name="size" id="size<?php echo $row['size']?>" value="<?php echo $row['size']?>" />
<label for="layered_id_attribute_group_86">
<?php echo $row['size']?>
</label>
</li>
<?php
}
?>
</ul>
</div>
<div class="layered_filter">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">Bredd</span>
<!--<span class="layered_close">
</span>-->
</div>
<ul id="ul_layered_id_attribute_group_4" class="col-lg-12 layered_filter_ul">
<?php include 'php/config.php';
$sql =mysql_query("select * from width");
while($row=mysql_fetch_array($sql)){
?>
<li class="nomargin hiddable col-lg-6">
<input type="radio" class="radio" name="layered_id_attribute_group_33" id="layered_id_attribute_group_33" value="33_4" />
<label for="layered_id_attribute_group_33">
<?php echo $row['width']?>
</label>
</li>
<?php
}
?>
</ul>
</div>
<div class="layered_filter">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">Bultmönster</span>
<!--<span class="layered_close">
</span>-->
</div>
<ul id="ul_layered_id_attribute_group_2" class="col-lg-12 layered_filter_ul">
<?php include 'php/config.php';
$sql =mysql_query("select * from bolt");
while($row=mysql_fetch_array($sql)){
?>
<li class="nomargin hiddable col-lg-6">
<input type="radio" class="radio" name="layered_id_attribute_group_8" id="layered_id_attribute_group_8" value="8_2" />
<label for="layered_id_attribute_group_8">
<?php echo $row['bolt']?>
</label>
</li>
<?php
}
?>
</ul>
</div>
<div class="layered_filter">
<div class="layered_subtitle_heading">
<span class="layered_subtitle">ET</span>
<!--<span class="layered_close">
</span>-->
</div>
<ul id="ul_layered_id_attribute_group_6" class="col-lg-12 layered_filter_ul">
<?php include 'php/config.php';
$sql =mysql_query("select * from offset");
while($row=mysql_fetch_array($sql)){
?>
<li class="nomargin hiddable col-lg-6">
<input type="radio" class="radio" name="layered_id_attribute_group_205" id="layered_id_attribute_group_205" value="205_6" />
<label for="layered_id_attribute_group_205">
<?php echo $row['offset']?>
</label>
</li>
<?php
}
?>
</ul>
</div>
</div>
<input type="hidden" name="id_category_layered" value="14" />
</form>
</div>
<div id="layered_ajax_loader" style="display: none;">
<p>
<img src="images/loader.gif" alt="" />
<br />Laddar...
</p>
</div>
</div>
<!-- /Block layered navigation module -->
</div>
<!-- Left Panel end -->
<div id="center_column" class="center_column col-xs-9 col-sm-9" >
<h1 class="page-heading product-listing"><span class="cat-name">Fälgar </span>
</h1>
<div class="content_sortPagiBar clearfix">
<div class="sortPagiBar clearfix">
<!-- /Sort products -->
<!-- nbr product/page -->
<!-- /nbr product/page -->
</div>
<div class="top-pagination-content clearfix">
<!-- Pagination -->
<div id="pagination" class="pagination clearfix">
<form class="showall" action="" method="get">
<div>
<input type="hidden" name="id_lang" value="9" />
<input type="hidden" name="id_category" value="14" />
<input type="hidden" name="controller" value="category" />
<input name="n" id="nb_item" class="hidden" value="1098" />
</div>
</form>
</div>
<?php
$sql =mysql_query("select * from items ");
$num_rows = mysql_num_rows($sql);
?>
<div class="product-count">
Visar <?php echo $num_rows; ?> artiklar
</div>
<!-- /Pagination -->
</div>
</div>
<!-- Products list -->
<!--ul-->
<div class="product_list grid row">
<?php
while($row=mysql_fetch_array($sql)){
?>
<!--li-->
<div class="ajax_block_product col-xs-6 col-sm-6 col-md-4 first-in-line first-item-of-tablet-line first-item-of-mobile-line">
<div class="layered" itemscope itemtype="http://schema.org/Product" >
<div class="layered_filter" >
<div class="product-image-container" >
<a class="product_img_link"href="#" title="<?php echo $row['model_name']?> " itemprop="url">
<img class="replace-2x img-responsive" src="admin/itempics/<?php echo $row['itemno']?>.jpg" alt="<?php echo $row['model_name']?> " title="<?php echo $row['cname']?> " width="250" height="250" itemprop="image" />
</a>
<div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="priceCurrency" content="SEK" />
</div>
</div>
</div>
<div class="layered_filter">
<h5 itemprop="name">
<a class="product-name" href="#" title="<?php echo $row['model_name']?> " itemprop="url" >
<b><?php echo $row['model_name'], $row['cname'], $row['itemno'], $row['size'], $row['width'], $row['offset'], $row['colour']?></b>
</a>
</h5>
<p class="product-desc" itemprop="description">
<?php echo $row['model_name']?>
</p>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="content_price">
<span itemprop="price" class="price product-price">
<?php echo $row['price']?> ,00 kr
</span>
<meta itemprop="priceCurrency" content="SEK" />
</div>
<div style="margin-bottom:10px;" class="button-container">
<a class="button ajax_add_to_cart_button btn btn-default" href="index.php?con=8" id="rims_add_cart<?php echo $row['items_id']; ?>" rel="nofollow" title="Lägg till i varukorgen" data-id-product="1338" data-value="<?php echo $row['items_id']; ?>" >
<span>Lägg till i varukorgen</span>
</a>
<a style="margin-top:5px;" itemprop="url" class="button lnk_view btn btn-default" href="index.php?con=11 & itemno=<?php echo $row['items_id']; ?>" title="View">
<span>Mer</span>
</a>
</div>
<div class="product-flags">
</div>
<script>
$("#rims_add_cart<?php echo $row['items_id']; ?>").click(function() {
var addcart = $(this).data('value');
$.ajax({
type: "GET",
url: "session_cart_items.php",
data: {addsessioncart : addcart},
//cache: false,
});
//alert($(this).data('value'));
});
</script>
</div>
<div class="functional-buttons clearfix">
</div>
</div><!-- .product-container> -->
</div><!--li end-->
<?php
}
?>
</div><!--ul end-->
</div>
</div>
</div>
</div>
</div><!-- #center_column -->
</div><!-- .row -->
</div><!-- #columns -->
</div><!-- .columns-container -->
<!-- Footer -->
</div><!-- #page -->
<script type="text/javascript" src="assets/js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.ui.mouse.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.ui.slider.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.ui.widget.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$('input[type="checkbox"]').click(function() {
if ($('input[type="checkbox"]:checked').length > 0) {
$('.layered >div').hide();
$('input[type="checkbox"]:checked').each(function() {
$('.layered >div[data-category=' + this.id + ']').show();
});
} else {
$('.layered >div').show();
}
});
</script>
</div>
</body>
</html>
This is my code for the above.. I am using php as backend .
Magento v1.7
How can I submit a form in the header.phtml by listening for changes on a radio button?
This is my code, if I change the radio buttons to a select dropdown it submits fine. I can't understand
$groupId = null;
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
/* Get the customer data */
$customer = Mage::getSingleton('customer/session')->getCustomer();
/* Get the customer's full name */
$customer = Mage::getModel('customer/customer')->load($customer->getId()) ;
$groupId = $customer->getGroupId();
}
$cookieGroupId = Mage::getModel('core/cookie')->get('customer_group_id');
if ($cookieGroupId) {
$groupId = $cookieGroupId;
}
?>
<div id="alt-nav-container">
<ul id="alt-nav">
<li class="icon-reorder"><span>Navigation</span></li>
</ul>
</div>
<div class="header-container">
<header class="header">
<h1>
<figure>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><span><?php echo $this->getLogoAlt() ?></span>
</a>
</figure>
</h1>
<div class="player-container">
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li class="control-left"><span class="play-button"></span><span class="pause-button"></span></li>
<li class="control-center"><strong>Playing: <span class="jp-track-title"></span></strong> by <span class="jp-composer-name"></span></li>
<li class="control-right"><span class="volume-on-button"></span><span class="volume-off-button"></span></li>
</ul>
<div class="jp-time-holder">
<div class="jp-current-time"></div>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-duration"></div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your Flash plugin.
</div>
</div>
</div>
</div>
<!--
<div style="z-index:9999;">
<?php
// var_export(get_class_methods(get_class($GroupId)));
?>
</div> -->
<div class="license-type">
<ul class="select-license-tab">
<li><span>Select your license type <sub class="icon-chevron-down"></sub></span>
<ul>
<li>
<div class="license-form">
<form action="<?php echo $this->getUrl('mcustomer/group/update') ?>" method="post" id="form-group-update" name="form-group-update">
<dl class="accordion">
<?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
<?php foreach($groups as $group){ ?>
<div class="license-item">
<dt>
<?php if($groupId != null && $group['value'] == $groupId):?>
<input id="license-type-<?php print $group['value'] ?>" name="validate-one-required" type="radio" value="<?php print $group['value'] ?>" class="required-entry validate-one-required" checked="checked" />
<label for="license-type-<?php print $group['value'] ?>"><?php print $group['label'] ?></label>
<?php else: ?>
<input id="license-type-<?php print $group['value'] ?>" name="validate-one-required" type="radio" value="<?php print $group['value'] ?>" class="required-entry validate-one-required" />
<label for="license-type-<?php print $group['value'] ?>"><?php print $group['label'] ?></label>
<?php endif; ?>
</dt>
<dd>
<?php print $group['customer_description'] ?>
</dd>
</div>
<?php } ?>
</dl>
</form>
</div>
</li>
</ul>
</li>
</ul>
</div>
</header>
</div>
<div class="navigation-bar">
<div class="navigation-bar-wrapper">
<?php echo $this->getChildHtml('topContainer'); ?>
<?php echo $this->getChildHtml('topSearch') ?>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
<?php echo $this->getChildHtml('topMenu') ?>
</div>
</div>
<script type="text/javascript">
//< ![CDATA[
var customForm = new VarienForm('form-group-update');
Event.observe($("validate-one-required"),'change', function(event){
$('form-group-update').submit();
});
//]]>
</script>
Thanks in advance
You should add a new class to your radio to prevent conflict with forms on other page since validate-one-required is not unique, or use more unique class selector eg $$('.license-form .validate-one-required').each..
$$('.license-form_radios').each(function(curInput) {
Event.observe(curInput, 'click', function() {
$('form-group-update').submit();
});
});