Top Questions

  • 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 : Php
    • Location : Chandigarh
    • Posted On : Dec 15, 2015
    <label for="fileToUpload"><img src="images/fileupload.png" id="blah1" width="50" height="50"/></label><input type="file" name="exmaple" id="fileToUpload" onchange="$('#blah1')[0].src = window.URL.createObjectURL(this.files[0])"  required>
    <style>
    .image-upload > input[type=file]
    {
        display: none !important;
     z-index: 0 !important;
    }
    </style>

     

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Nov 19, 2016

    split time interval in 15 min slot using php

    $array_of_time = array ();
    $start_time    = strtotime ("2013-08-28 17:45:00");
    $end_time      = strtotime ("2013-08-28 22:15:00");
    
    $fifteen_mins  = 15 * 60;
    
    while ($start_time <= $end_time)
    {
       $array_of_time[] = date ("Y-m-d H:i:s", $start_time);
       $start_time  = $fifteen_mins;
    }
    
    print_r ($array_of_time);
     
  • 5.11 Years

    • Category : Wordpress
    • Location : Chandigarh, India
    • Posted On : Feb 20, 2018

    The hook allows meta box registration for any post type. Passes two parameters: $post_type and $post. Note: You can also use add_meta_boxes_{post_type} for best practice, so your hook will only run when editing a specific post type. This will only receive 1 parameter - $post.

    Add this to functions.php
    add_action( 'add_meta_boxes', 'gp_add_meta_boxes' );
    function gp_add_meta_boxes() {
        add_meta_box( 'gp_product', 'Products Options', 'gp_products_callback', 'review', 'normal', 'high' );
    }
    
    function gp_products_callback( $post ) {
        $fname = get_post_meta( $post->ID, 'fname', true );
    
    // reset choices
    	$field['choices'] = array();
    	
    	$users = get_users();
    	?>
    	<select name="cust_user"></select>
    	<?php
    	foreach ($users as $user) {
    		$field[ $user->ID ] = $user->display_name;
    	}
    
        ?>
        <p>First Name: <input type="text" name="fname" value="<?php echo $fname; ?>"></p>
        <?php
    }
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Dec 30, 2015
    echo mt_rand(1, 9999999);

     

  • 0.0 Years

    • Category : Wordpress
    • Location : Unknown
    • Posted On : Mar 22, 2016

    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 ?>
    
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Mar 17, 2016
    <script type="text/javascript">
    
    var cssfeed=new gfeedfetcher("example1", "example1class", "")
    cssfeed.addFeed("CSS Drive", "your rss link") //Specify "label" plus URL to RSS feed
    cssfeed.displayoptions("date") //show the specified additional fields
    cssfeed.setentrycontainer("li") //Display each entry as a list (li element)
    cssfeed.filterfeed(10, "title") //Show 10 entries, sort by date
    cssfeed.init() //Always call this last
    
    </script>

     

  • 5.11 Years

    • Category : Php
    • Location : Chandigarh, India
    • Posted On : Jul 31, 2016

    In order to generate token for access to api and other

    Here is the correct solution:
    $token = bin2hex(openssl_random_pseudo_bytes(16));
     
  • 2.9 Years

    • Category : Wordpress
    • Location : Chandigarh
    • Posted On : Apr 1, 2016

    Upload multiple video file and store its in database using this code.

    <?php
    $server_url="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["REQUEST_URI"].'?').'/';
    $path = preg_replace('/wp-content.*$/','',__DIR__);
    $path = preg_replace('/wp-content(?!.*wp-content).*/','',__DIR__);
    include($path.'wp-load.php');
    /******Database Connect end*******/
    if(isset($_POST['add']))
    {
    $_FILES["fileToUpload"]["name"];
    if ( ! function_exists( 'wp_handle_upload' ) ) {
    require_once( ABSPATH . 'wp-admin/includes/file.php' ); }
    $upload_overrides = array( 'test_form' => false );
     $files = $_FILES["fileToUpload"]; 
        foreach ($files['name'] as $key => $value) {           
                if ($files['name'][$key]) {
                    $file = array(
                        'name' => $files['name'][$key],
                        'type' => $files['type'][$key],
                        'tmp_name' => $files['tmp_name'][$key],
                        'error' => $files['error'][$key],
                        'size' => $files['size'][$key]
                    );
    
                   $_name = $file['name'];
                   $f_name =  explode('.', $_name);
                    $rand = rand(0000,9999);
                   $addname = $f_name['0'].$rand;
                   $total_name = $addname."." .$f_name['1'];
    
                  $insertname[] = $total_name;
    
    
    
                   $file_s = array( 'name' =>  $total_name,
                        'type' => $files['type'][$key],
                        'tmp_name' => $files['tmp_name'][$key],
                        'error' => $files['error'][$key],
                        'size' => $files['size'][$key]
                    );
    
    
    
    
                 
    
                    
                        $newupload = wp_handle_upload($file_s,$upload_overrides);
                      $patoooooooooh[] = $newupload['url'];
                   
                }
            }
    $nname=implode("&",$patoooooooooh);
    mysql_query("insert table_name (`column_name`) values ('$nname')");
    }
    ?>
    /*****Php Code end and html start*****/
    <form class="form-horizontal" method="post" enctype="multipart/form-data">
    <input type="file" name="fileToUpload[]" id="fileToUpload" class="add_file">
    <div class="demo">
    </div>
    <button name="add" type="submit">Add</button>
    </form>
    /********Html End & jquery Start**************/
    
    <script>
    $(document).ready(function() {
    // $('.add_field_button').keyup(function(e){
      var rand=Math.random();
    $(document).on('change','.add_file',function(e){
      //on add input button click
            e.preventDefault();
                $('.demo').append("<div class='sas'><br/><input type='file' name='fileToUpload[]' class='add_file' ><a href='#' class='remove_field'><i class='fa fa-trash-o'></i></a></div>"); //add input box
        });
      $('.demo').on('click', '.remove_field', function(e) {
        $(this).closest('.sas').remove();
      return false;
    });
    });
    </script>
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Dec 16, 2015
    ALTER TABLE tablename AUTO_INCREMENT = 1