Top Questions

  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Sep 15, 2016

    fix “Headers already sent” error in PHP

    The very quick fix for your problem will be to add

    ob_start();
    as the very first thing in your script if you only need it in this one script. If you need it in all your scripts add it as the very first thing in your header.php file.
  • 5.11 Years

    • Category : Jquery
    • Location : Mohali
    • Posted On : Jun 9, 2016

    I use a datepicker for choosing an appointment day.I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how?

    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <input name="datenew" type="text" id="datepicker">
    <script>
    var unavailableDates = ["21-6-2016","22-6-2016","23-6-2016","24-6-2016"];
    function unavailable(date) {
      var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
        dmy = date.getDate()   "-"   (date.getMonth()   1)   "-"   date.getFullYear();
      var closedDays = [[Saturday],[Sunday]];
     for (var i = 0; i < closedDays.length; i  ) {
        if (day == closedDays[i][0]) {
          return [false];
       }
    
     }
        if (jQuery.inArray(dmy, unavailableDates) == -1) {
            return [true, ""];
        } else {
            return [false, "", "Unavailable"];
        }
    }
    jQuery(function() {
      jQuery( "#datepicker" ).datepicker({    
        changeMonth: true,
        changeYear: true,
       dateFormat: 'dd MM yy',   
        autoclose: true,
        minDate:  2,
        firstDay: 1,
        beforeShowDay: unavailable
      });
    
    });
    </script>
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jun 5, 2016

    Display limited o of word from a string using this code

    echo mb_strimwidth('It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using Content here, content here, making it look like readable English', 0, 50, "...");
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jun 2, 2016

    Get last week start and end date in php

    $previous_week = strtotime("-1 week  1 day");
    
    $start_week = strtotime("last sunday midnight",$previous_week);
    $end_week = strtotime("next saturday",$start_week);
    
    $start_week = date("Y-m-d",$start_week);
    $end_week = date("Y-m-d",$end_week);
    
    echo $start_week.' '.$end_week ;
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : May 27, 2016

    I am fairly new to woocommerce and although the other day the add to cart and cart page was displaying fine. I am now finding that going to my cart page brings up a blank page.

    add this code in function.php
    add_filter('woocommerce_add_to_cart', 'custome_add_to_cart');
    function custome_add_to_cart() {
        global $woocommerce;
     $woocommerce->session->set_customer_session_cookie(true);
    }
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Apr 28, 2016

    woo-commerce cart item session start and destroy after 30 Min

    <?php
    
    global $woocommerce;
    if (!isset($_SESSION['EXPIRES']) || $_SESSION['EXPIRES'] < time()) {
     $woocommerce->cart->empty_cart(); 
    } else {
      $_SESSION['EXPIRES'] = time() 1800;
    }
    
  • 2.9 Years

    • Category : Ajax
    • Location : Chandigarh
    • Posted On : Apr 25, 2016

    print your custom data or field using ajax

    function printinvoice(id){
         $.ajax({
           url: "sample.php",            
                type: "POST",
           data: "print_id=" id,
          success: function(data) {
         newWin= window.open();
                            newWin.document.write(data);
                            newWin.document.close();
                            newWin.focus();
                            newWin.print();
                             newWin.close();
          },
      error: function() {
         
          }
       }); 
    }
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Apr 18, 2016

    When i click the first upload field (uploading process are success) after insert into post that corresponding media url is appear in the second field not in first. I am not sure where is the problem any suggestion would be great.

    <?php
    wp_enqueue_script('jquery');
    // This will enqueue the Media Uploader script
    wp_enqueue_media();
    ?>
        <div>
        <label for="image_url">Image</label>
        <input type="text" name="image_url" id="image_url" class="regular-text">
        <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Upload Image">
     </div>
    <script type="text/javascript">
    
    jQuery(document).ready(function($){
        $('#upload-btn').click(function(e) {
            e.preventDefault();
            var image = wp.media({ 
                title: 'Upload Image',
                // mutiple: true if you want to upload multiple files at once
                multiple: false
            }).open()
            .on('select', function(e){
                // This will return the selected image from the Media Uploader, the result is an object
                var uploaded_image = image.state().get('selection').first();
                // We convert uploaded_image to a JSON object to make accessing it easier
                // Output to the console uploaded_image
                console.log(uploaded_image);
                var image_url = uploaded_image.toJSON().url;
                // Let's assign the url value to the input field
                $('#image_url').val(image_url);
            });
        });
    });
    </script>
    
    
    
    // UPLOAD ENGINE
    function load_wp_media_files() {
        wp_enqueue_media();
    }
    add_action( 'admin_enqueue_scripts', 'load_wp_media_files' );
     
  • 2.9 Years

    • Category : Mysql
    • Location : Chandigarh
    • Posted On : Apr 15, 2016

    Foreign Key integration between two tables

    $id='15';
    mysql_query("select table1.column1,table1.column2,table1.column3, table1.column4, table2.column1, table2.column2, table2.column3, from table1name table1, table2name table2 where table2.column1=table2.column1 and table1.column1='$id'");
     
  • 2.9 Years

    • Category : Mysql
    • Location : Chandigarh
    • Posted On : Mar 31, 2016

    This code resolve special character problem during fetch data from database.just copy and paste code where you create your connection.

    //copy in config file
    mysql_set_charset('utf8');