473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to work with Add-To-Cart functionality?

aveeva
33
How to work with Add-To-Cart functionality?
My code about filterable audio searching, here how can i add Add-To-Cart functionality?

code :



index.php

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. //index.php
  4.  
  5. include('database_connection.php');
  6.  
  7. ?>
  8.  
  9. <!DOCTYPE html>
  10. <html lang="en">
  11.  
  12. <head>
  13.  
  14.     <meta charset="utf-8">
  15.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  16.     <meta name="viewport" content="width=device-width, initial-scale=1">
  17.     <meta name="description" content="">
  18.     <meta name="author" content="">
  19.  
  20.     <title>Voice Repository</title>
  21.  
  22.     <script src="js/jquery-1.10.2.min.js"></script>
  23.     <script src="js/jquery-ui.js"></script>
  24.     <script src="js/bootstrap.min.js"></script>
  25.     <link rel="stylesheet" href="css/bootstrap.min.css">
  26.     <link href = "css/jquery-ui.css" rel = "stylesheet">
  27.     <!-- Custom CSS -->
  28.     <link href="css/style.css" rel="stylesheet">
  29. </head>
  30.  
  31. <body>
  32.     <!-- Page Content -->
  33.     <div class="container">
  34.         <div class="row">
  35.             <br />
  36.             <div class="col-md-12">
  37.                 <h2 align="center">Voice Repository Bank</h2>
  38.             </div>
  39.             <div class="col-md-3">
  40.  
  41.                 <!-- Price -->
  42.                 <!-- <div class="list-group">
  43.                     <h3>Price</h3>
  44.                     <input type="hidden" id="hidden_minimum_price" value="0" />
  45.                     <input type="hidden" id="hidden_maximum_price" value="65000" />
  46.                     <p id="price_show">1000 - 65000</p>
  47.                     <div id="price_range"></div>
  48.                 </div> -->
  49.  
  50.                 <!-- Languages  -->
  51.                 <div class="list-group">
  52.                     <h3>Languages</h3>
  53.                     <?php
  54.                     $query = "
  55.                     SELECT DISTINCT(voice_languages) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_languages DESC
  56.                     ";
  57.                     $statement = $connect->prepare($query);
  58.                     $statement->execute();
  59.                     $result = $statement->fetchAll();
  60.                     foreach($result as $row)
  61.                     {
  62.                     ?>
  63.                     <div class="list-group-item checkbox">
  64.                         <label><input type="checkbox" class="common_selector languages" value="<?php echo $row['voice_languages']; ?>"  > <?php echo $row['voice_languages']; ?> </label>
  65.                     </div>
  66.                     <?php
  67.                     }
  68.                     ?>    
  69.                 </div>
  70.  
  71.                 <!-- Genres  -->
  72.                 <div class="list-group">
  73.                     <h3>Genres</h3>
  74.                     <?php
  75.  
  76.                     $query = "
  77.                     SELECT DISTINCT(voice_genres) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_genres DESC
  78.                     ";
  79.                     $statement = $connect->prepare($query);
  80.                     $statement->execute();
  81.                     $result = $statement->fetchAll();
  82.                     foreach($result as $row)
  83.                     {
  84.                     ?>
  85.                     <div class="list-group-item checkbox">
  86.                         <label><input type="checkbox" class="common_selector genres" value="<?php echo $row['voice_genres']; ?>" > <?php echo $row['voice_genres']; ?> </label>
  87.                     </div>
  88.                     <?php    
  89.                     }
  90.  
  91.                     ?>
  92.                 </div>
  93.  
  94.                 <!-- Voice Modulation -->
  95.                 <div class="list-group">
  96.                     <h3>Voice Modulation</h3>
  97.                     <?php
  98.                     $query = "
  99.                     SELECT DISTINCT(voice_voice_modulation) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_voice_modulation DESC
  100.                     ";
  101.                     $statement = $connect->prepare($query);
  102.                     $statement->execute();
  103.                     $result = $statement->fetchAll();
  104.                     foreach($result as $row)
  105.                     {
  106.                     ?>
  107.                     <div class="list-group-item checkbox">
  108.                         <label><input type="checkbox" class="common_selector voice_modulation" value="<?php echo $row['voice_voice_modulation']; ?>"  > <?php echo $row['voice_voice_modulation']; ?> </label>
  109.                     </div>
  110.                     <?php
  111.                     }
  112.                     ?>    
  113.                 </div> 
  114.                 <!-- Gender  -->
  115.                 <div class="list-group">
  116.                     <h3>Gender</h3>
  117.                     <div style="height: 180px; overflow-y: auto; overflow-x: hidden;">
  118.                     <?php
  119.  
  120.                     $query = "SELECT DISTINCT(voice_gender) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_id DESC";
  121.                     $statement = $connect->prepare($query);
  122.                     $statement->execute();
  123.                     $result = $statement->fetchAll();
  124.                     foreach($result as $row)
  125.                     {
  126.                     ?>
  127.                     <div class="list-group-item checkbox">
  128.                         <label><input type="checkbox" class="common_selector gender" value="<?php echo $row['voice_gender']; ?>"  > <?php echo $row['voice_gender']; ?></label>
  129.                     </div>
  130.                     <?php
  131.                     }
  132.  
  133.                     ?>
  134.                     </div>
  135.                 </div>
  136.  
  137.  
  138.                 <!-- Jingle Moods -->
  139.                 <div class="list-group">
  140.                     <h3>Jingle Moods</h3>
  141.                     <?php
  142.                     $query = "
  143.                     SELECT DISTINCT(voice_jingle_moods) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_jingle_moods DESC
  144.                     ";
  145.                     $statement = $connect->prepare($query);
  146.                     $statement->execute();
  147.                     $result = $statement->fetchAll();
  148.                     foreach($result as $row)
  149.                     {
  150.                     ?>
  151.                     <div class="list-group-item checkbox">
  152.                         <label><input type="checkbox" class="common_selector jingle_moods" value="<?php echo $row['voice_jingle_moods']; ?>"  > <?php echo $row['voice_jingle_moods']; ?> </label>
  153.                     </div>
  154.                     <?php
  155.                     }
  156.                     ?>    
  157.                 </div>
  158.  
  159.                 <!-- IVR -->
  160.                 <div class="list-group">
  161.                     <h3>Ivr</h3>
  162.                     <?php
  163.                     $query = "
  164.                     SELECT DISTINCT(voice_ivr) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_ivr DESC
  165.                     ";
  166.                     $statement = $connect->prepare($query);
  167.                     $statement->execute();
  168.                     $result = $statement->fetchAll();
  169.                     foreach($result as $row)
  170.                     {
  171.                     ?>
  172.                     <div class="list-group-item checkbox">
  173.                         <label><input type="checkbox" class="common_selector ivr" value="<?php echo $row['voice_ivr']; ?>"  > <?php echo $row['voice_ivr']; ?> </label>
  174.                     </div>
  175.                     <?php
  176.                     }
  177.                     ?>    
  178.                 </div>
  179.             </div>
  180.  
  181.             <div class="col-md-9">
  182.                 <br />
  183.                 <div class="row filter_data">
  184.  
  185.                 </div>
  186.             </div>
  187.         </div>
  188.  
  189.     </div>
  190. <style>
  191. #loading
  192. {
  193.     text-align:center; 
  194.     background: url('loader.gif') no-repeat center; 
  195.     height: 150px;
  196. }
  197. </style>
  198.  
  199. <script>
  200. $(document).ready(function(){
  201.  
  202.     filter_data();
  203.  
  204.     function filter_data()
  205.     {
  206.         $('.filter_data').html('<div id="loading" style="" ></div>');
  207.         var action = 'fetch_data';
  208.  
  209.         // var minimum_price = $('#hidden_minimum_price').val();
  210.         // var maximum_price = $('#hidden_maximum_price').val();
  211.  
  212.         var gender = get_filter('gender');
  213.         var genres = get_filter('genres');
  214.         var voice_modulation = get_filter('voice_modulation');
  215.         var languages = get_filter('languages');
  216.         var jingle_moods = get_filter('jingle_moods');
  217.         var ivr = get_filter('ivr');
  218.         $.ajax({
  219.             url:"fetch_data.php",
  220.             method:"POST",
  221.             data:
  222.             {
  223.                 action:action, 
  224.                 // minimum_price:minimum_price, 
  225.                 // maximum_price:maximum_price,
  226.                 gender:gender,
  227.                 genres:genres, 
  228.                 voice_modulation:voice_modulation,
  229.                 languages:languages,
  230.                 jingle_moods:jingle_moods,
  231.                 ivr:ivr
  232.             },
  233.                 success:function(data)
  234.                 {
  235.                 $('.filter_data').html(data);
  236.                 }
  237.         });
  238.     }
  239.  
  240.     function get_filter(class_name)
  241.     {
  242.         var filter = [];
  243.         $('.'+class_name+':checked').each(function(){
  244.             filter.push($(this).val());
  245.         });
  246.         return filter;
  247.     }
  248.  
  249.     $('.common_selector').click(function(){
  250.         filter_data();
  251.     });
  252.  
  253.     // $('#price_range').slider({
  254.     //     range:true,
  255.     //     min:1000,
  256.     //     max:65000,
  257.     //     values:[1000, 65000],
  258.     //     step:500,
  259.     //     stop:function(event, ui)
  260.     //     {
  261.     //         $('#price_show').html(ui.values[0] + ' - ' + ui.values[1]);
  262.     //         $('#hidden_minimum_price').val(ui.values[0]);
  263.     //         $('#hidden_maximum_price').val(ui.values[1]);
  264.     //         filter_data();
  265.     //     }
  266.     // });
  267.  
  268. });
  269. </script>
  270. </body>
  271. </html>
and my



data fetching file,

data_fetch.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //fetch_data.php
  4.  
  5. include('database_connection.php');
  6.  
  7. if(isset($_POST["action"]))
  8. {
  9.     $query = "
  10.         SELECT * FROM voice_bank_data WHERE voice_status = '1'
  11.     ";
  12.  
  13.     // if(isset($_POST["minimum_price"], $_POST["maximum_price"]) && !empty($_POST["minimum_price"]) && !empty($_POST["maximum_price"]))
  14.     // {
  15.     //     $query .= "
  16.     //      AND product_price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."'
  17.     //     ";
  18.     // }
  19.  
  20.     // Gender
  21.     if(isset($_POST["gender"]))
  22.     {
  23.         $gender_filter = implode("','", $_POST["gender"]);
  24.         $query .= "
  25.          AND voice_gender IN('".$gender_filter."')
  26.         ";
  27.     }
  28.  
  29.     // Genres
  30.     if(isset($_POST["genres"]))
  31.     {
  32.         $genres_filter = implode("','", $_POST["genres"]);
  33.         $query .= "
  34.          AND voice_genres IN('".$genres_filter."')
  35.         ";
  36.     }
  37.  
  38.     // Voice Modulation
  39.     if(isset($_POST["voice_modulation"]))
  40.     {
  41.         $voice_modulation_filter = implode("','", $_POST["voice_modulation"]);
  42.         $query .= "
  43.          AND voice_voice_modulation IN('".$voice_modulation_filter."')
  44.         ";
  45.     }
  46.  
  47.  
  48.     // Languages
  49.     if(isset($_POST["languages"]))
  50.     {
  51.         $languages_filter = implode("','", $_POST["languages"]);
  52.         $query .= "
  53.          AND voice_languages IN('".$languages_filter."')
  54.         ";
  55.     }
  56.  
  57.     // Jingle Moods
  58.     if(isset($_POST["jingle_moods"]))
  59.     {
  60.         $jingle_moods_filter = implode("','", $_POST["jingle_moods"]);
  61.         $query .= "
  62.          AND voice_jingle_moods IN('".$jingle_moods_filter."')
  63.         ";
  64.     }
  65.  
  66.     // IVR
  67.     if(isset($_POST["ivr"]))
  68.     {
  69.         $ivr_filter = implode("','", $_POST["ivr"]);
  70.         $query .= "
  71.          AND voice_ivr IN('".$ivr_filter."')
  72.         ";
  73.     }
  74.  
  75.     $statement = $connect->prepare($query);
  76.     $statement->execute();
  77.     $result = $statement->fetchAll();
  78.     $total_row = $statement->rowCount();
  79.     $output = '';
  80.     if($total_row > 0)
  81.     {
  82.         foreach($result as $row)
  83.         {
  84.             $output .= '
  85.             <div class="col-sm-3 col-lg-4 col-md-3">
  86.                 <div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;">
  87.                     <audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;">
  88.                         <source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive">
  89.                     </audio>
  90.                     <p align="center"><strong> '. $row['voice_name'] .'</strong></p>
  91.  
  92.                     <p style="font-size: 12px;">
  93.                     Gender              : '. $row['voice_gender'].' <br />
  94.                     Genres               : '. $row['voice_genres'].' <br />
  95.                     Voice Modulation  : '. $row['voice_voice_modulation'].' <br />
  96.                     Languages          : '. $row['voice_languages'].' <br />
  97.                     Jingle Moods      : '. $row['voice_jingle_moods'].' <br />
  98.                     Ivr               : '. $row['voice_ivr'].' <br /> </p>
  99.                     <button class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;"> Add to PlayList </button>
  100.                 </div>
  101.  
  102.             </div>
  103.             ';
  104.         } 
  105.     }
  106.     else 
  107.     {
  108.         $output = '<h3>No Data Found</h3>';
  109.     }
  110.     echo $output;
  111. }
  112. ?>
How can i add add-to-cart functionality.



Note : In the cart just voice_id, voice_name, not necessary qty & price.



My current output:

Jun 10 '19 #1
0 1104

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
3
by: Reetu | last post by:
Hi All, I have an html button on .aspx page. <INPUT class="sbttn" id="btnComplete0" onclick="onComplete ()" type="button" value="Mark Completed" name="btnComplete0"> When the user clicks...
4
by: John | last post by:
I get the feeling this is a pretty classic problem, but I'm a bit of an uber newber. Apologies! Products page, user enters a quantity and clicks one of my "Add to Cart" buttons, which bubbles up...
5
by: Hogan's Goat | last post by:
OK, I've written a pretty cool little app that I think would be broadly interesting. Now I'd like to make money from it! Here are my options, as I see them: 1) Advertise it heavily, then sell...
1
by: sheldongold | last post by:
Hi, I'm coding in PHP4 and MYSQL4 and there is a teensy bit of JS in there as well. I'm haveing trouble with my dropdown lists as when there is more than one on the page it just says 'error on...
13
by: Wayne | last post by:
I have just experienced my first late paying client. By "late" I mean that the invoice is now almost 2 months overdue. I don't think that the client is maliciously withholding payment - rather...
0
by: Bogus Exception | last post by:
Forgive me if this group is for the discussion of pure VB.NET language topics. My question may be more about add-on components to VB.NET that will allow the functionality I'm looking for. I'm very...
1
by: jholg | last post by:
Hi, regarding automatically adding functionality to a class (basically taken from the cookbook recipee) and Python's lexical nested scoping I have a question wrt this code: #-----------------...
19
by: John Salerno | last post by:
Hey all. Just thought I'd ask a general question for my own interest. Every time I think of something I might do in Python, it usually involves creating a GUI interface, so I was wondering what kind...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.