Top Questions:

  • 3 years-4 months

    Resolve Special Character Mysql

    • Category : mysql
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley

    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');
     
  • 3 years-4 months

    Generate Random Refer Code

    • Category : php
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley

    You can generate refer code or random code using this code in php.its easy to implement and use.

    <?php
        $character_set_array = array();
        $character_set_array[] = array('count' => 6, 'characters' => 'abcdefghijklmnopqrstuvwxyz');
        $character_set_array[] = array('count' => 1, 'characters' => '0123456789');
        $character_set_array[] = array('count' => 1, 'characters' => '!@#$ -*&?:');
        $temp_array = array();
        foreach ($character_set_array as $character_set) {
            for ($i = 0; $i < $character_set['count']; $i   ) {
                $temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
            }
        }
        shuffle($temp_array);
        $refercode= implode('', $temp_array);
        echo $refercode;
        ?>
  • 0 year-0 month

    Get Post By Sub Category ID

    • Category : wordpress
    • Location : Unknown
    • Posted On :
    • Posted by : Narinder

    Get Posts By Sub Category ID in Wordpress.

    <?php query_posts('cat=10&showposts=-1');
               $posts = get_posts('category=10&numberposts=3&offset=0');
                foreach ($posts as $post) : start_wp(); ?>
    
                <?php $cats = get_the_category($post->ID);
                $subcategories = array();
                foreach( $cats as $cat ) {
                $subcats = get_categories('child_of='.$cat->term_id);
                if($subcats) {
                foreach( $subcats as $subcat )
                {  $subcategories[] = sanitize_title($subcat->name); }
                }
                }
                $subcats = array_unique($subcategories);
                if($subcats) {
                $subcats = implode(' ',$subcats);
                $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );
               // echo '<li class="' . $subcats . '">';
    
                }
                ?>
                    <figure class="mix portfolio-item print">
                        <img class="img-responsive" src="<?php echo $url; ?>" alt="Portfolio Item">
                        <a href="<?php echo $url; ?>" title="Title Four" rel="portfolio" class="fancybox"><span class="plus"></span></a>
                        <figcaption class="mask">
                            <h3><?php the_title(); ?></h3>
                            <span><?php the_content(); ?></span>
                        </figcaption>
                    </figure>
    
    <?php endforeach ?>
    
  • 3 years-4 months

    Loader

    • Category : html
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley
    <html>
    <head>
    <style>
      .js div#preloader { position: fixed; left: 0; top: 0; z-index:99999; width: 100%; height: 100%; overflow: visible; background:#FFFFFF url('images/load.gif') no-repeat center center;background-size:30%;}
    .ui-loader.ui-corner-all.ui-body-a.ui-loader-default {display: none;}
      </style>
    </head>
     <div class="js">
    <body>
    <div id="preloader"></div> 
    </body>
    </div>
    </html>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    /*====================================================== start */
    
    
    jQuery(document).ready(function($) {  
    
    // site preloader -- also uncomment the div in the header and the css style for #preloader
    $(window).load(function(){
      $('#preloader').fadeOut('10000',function(){$(this).remove();});
    });
    });
    /*====================================================== end */
    </script>

     

  • 3 years-4 months

    Get Number Of Blank Colums From Db in Percentage

    • Category : php
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley

    Fetch blank colum information from database in %.

    <div class="progress">
    
    <?php
    $result = mysql_query("SELECT * FROM `register_users` where `uemail`='$email'");
    while($row = mysql_fetch_row($result)){
        $empty_count = 0;
        $count = count($row);
        for($i = 0; $i < $count; $i  )
            if($row[$i] === '' || $row[$i] === 'NULL')
                $empty_count  ;
       
    
    ?>
      <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="<?php echo  ''.((int)(100*(1-$empty_count/($count-1)))).'' ?>"
      aria-valuemin="0" aria-valuemax="100" style="width:30%;border: 1px solid #ccc !important;">
     <?php    echo  ''.((int)(100*(1-$empty_count/($count-1)))).'% complete'; ?>
      </div>
      <?php } ?>
    </div>

     

  • 3 years-4 months

    Custom Menu Page

    • Category : wordpress
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley
    /**
     * Register a custom menu page.
     */
    function wpdocs_register_my_custom_menu_page() {
        add_menu_page(
            __( 'Bookings', 'textdomain' ),
            'Bookings',
            'manage_options',
            'admin.php?page=booking_diplay',
            'booking_display',
            plugins_url( 'bookin1.png' ),
            6
        );
    }
    add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' );
    function booking_display()
    {
     require_once(plugin_dir_path(__FILE__).'booking_display.php');
    }

     

  • 3 years-4 months

    Get Child Category By Parent Category Id

    • Category : wordpress
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley
    <?php
    $deptID = "7";
    $childCatID = $wpdb->get_col("SELECT term_id FROM $wpdb->term_taxonomy WHERE parent=$deptID");
    if ($childCatID){
    foreach ($childCatID as $kid)
    {
    $childCatName = $wpdb->get_row("SELECT name, term_id FROM $wpdb->terms WHERE term_id=$kid");
    echo $childCatName->term_id;
    echo $childCatName->name;
    }
    ?>

     

  • 3 years-4 months

    Call Posts By Category Id

    • Category : wordpress
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley
    <?php
        global $post;
        $args = array( 'numberposts' => 10, 'category' => 6 );
        $posts = get_posts( $args );
        foreach( $posts as $post ): setup_postdata($post); 
    ?>
    
        <divs with the_title() the_excerpt() etc ></div>
    
    <?php 
        endforeach; 
    ?>

     

  • 3 years-4 months

    Menu Active

    • Category : jquery
    • Location : Chandigarh
    • Posted On :
    • Posted by : Guley
    $(function(){
        // this will get the full URL at the address bar
        var url = window.location.href; 
        // passes on every "a" tag 
        $(".main-nav li a").each(function() {
                // checks if its the same on the address bar
            if(url == (this.href)) { 
                $(this).closest("li").addClass("current");
            }
        });
    });

     

  • 5 years-11 months

    .htaccess Tricks To Speed Up Your Website

    • Category : htaccess
    • Location : Chandigarh, India
    • Posted On :
    • Posted by : Vikas

    Speed-up your website with these simple .htaccess tricks

    # Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
    RewriteBase /
    
    # BEGIN Cache-Control Headers
    <ifModule mod_headers.c>
     <filesMatch ".(ico|jpe?g|png|gif|swf)$">
       Header set Cache-Control "public"
     </filesMatch>
     <filesMatch ".(css)$">
       Header set Cache-Control "public"
     </filesMatch>
     <filesMatch ".(js)$">
       Header set Cache-Control "private"
     </filesMatch>
     <filesMatch ".(x?html?|php)$">
       Header set Cache-Control "private, must-revalidate"
     </filesMatch>
    </ifModule>
    # END Cache-Control Headers
    
    <ifmodule mod_expires.c>
    <Filesmatch "\.(jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3)$">
        ExpiresActive on
        ExpiresDefault A2592000
    </Filesmatch>
    </ifmodule>