Top Questions

  • 5.11 Years

    • Category : Php
    • Location : Chandigarh, India
    • 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');
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Mar 30, 2016

    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;
        ?>
  • 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>

     

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Mar 9, 2016

    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>

     

  • 2.9 Years

    • Category : Wordpress
    • Location : Chandigarh
    • Posted On : Mar 8, 2016
    <?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;
    }
    ?>

     

  • 2.9 Years

    • Category : Wordpress
    • Location : Chandigarh
    • Posted On : Mar 8, 2016
    <?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; 
    ?>